我是否可以将这两行shell脚本切成一行。
我的两行代码回显相同的字符串,但一行进入控制台,另一行进入日志文件。
echo "Starting scriptr" `date '+%T'` >> script.log
echo "Starting script" `date '+%T'`
由于
答案 0 :(得分:4)
使用tee
:
echo "Starting scriptr" `date '+%T'` | tee script.log
要附加到日志文件,请说出 tee -a
引自man tee
:
tee - read from standard input and write to standard output and files