029_shell编写工作常用工具类总结

一、检查命令的执行结果

function check_result() {
    result=$?
    flag=$1
    if [[ "$result"x == "0"x ]];then
        echo "###############$flag is OK.###############"
    else
        echo "###############$flag is Failed.###########"
        exit -1
    fi
}

调用

check_result "cat conf/channel.conf > flume-agent.properties"
原文地址:https://www.cnblogs.com/itcomputer/p/9754477.html