-1

我写了一些丑陋的脚本,除了在输出中给我想要的东西之外,它还给了我状态码值。

脚本输出如下。如何防止脚本在输出中显示该状态代码?

PS我会把脚本放在下面,希望不会太伤你的眼睛

    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
4

1 回答 1

0

您应该决定您想要达到的目标,其中一种方法可以是例如:

(
your commands
) 2>&1 | grep -v 'Status code = 0'

当心 - 以上不是一个好的做法 - 只是一个快速破解之类的解决方案......

于 2014-03-28T12:25:14.937 回答