我写了一些丑陋的剧本,除了在输出中给出了我想要的东西,它还给了我状态代码值。
脚本输出如下。如何防止脚本在输出中显示状态代码?
P.S。我将脚本放在下面,希望它不会太伤害你的眼睛
Status code = 0
Status code = 0
Status code = 0
job_1_1_1
Status code = 0
Status code = 0
Status code = 0
Status code = 0
Status code = 0
Status code = 0
job_1_1_2
Status code = 0
Status code = 0
START_ID=`dsjob -logsum -type STARTED UPSTREAM_MDM_D4 seq_1_1 | nawk 'ORS=(FNR%2)?FS:RS' | grep Starting | tail -1 | awk '{print $1 }'`; FATAL_IDS=`dsjob -logsum -type INFO UPSTREAM_MDM_D4 seq_1_1 | grep INFO | awk '{print $1 }'`; for TEST_ID in ${FATAL_IDS}; do if [[ "${TEST_ID}" -ge "${START_ID}" ]]; then WARN_DTL=`dsjob -logdetail UPSTREAM_MDM_D4 seq_1_1 ${TEST_ID}`; if `echo $WARN_DTL|grep -q 'has finished, status = 3'`; then message=`echo $WARN_DTL| grep -oP '\w+(?= has finished, status = 3)'`; fatal_errors=$fatal_errors$'\n'$message;fi; fi;done; echo $fatal_errors
答案 0 :(得分:0)
你应该决定你想要实现什么,例如,方法之一可以是:
(
your commands
) 2>&1 | grep -v 'Status code = 0'
小心 - 以上不是一个好习惯 - 只是一个快速破解的解决方案......