【发布时间】:2014-08-01 09:51:31
【问题描述】:
我仅将 STDERR 重定向到文件(或多或少有效),但我还想为每个重定向添加/添加时间戳。我不想要每一行的时间,只是在块的开头。我试过这个:
UKMAC08:~ san$ ( date 1>&2; df -jj ) 2>&1 1>/dev/null 2>testErr.log; cat testErr.log
Fri 1 Aug 2014 10:50:00 BST
df: illegal option -- j
usage: df [-b | -H | -h | -k | -m | -g | -P] [-ailn] [-T type] [-t] [filesystem ...]
这是在为不成功的运行做我想做的事情,但在成功时也会加上时间戳:
UKMAC08:~ san$ ( date 1>&2; df -h ) 2>&1 1>/dev/null 2>testErr.log; cat testErr.log
Fri 1 Aug 2014 10:50:07 BST
我怎样才能避免这种情况。最好的!
【问题讨论】: