1

我能不能把这两行shell脚本剪成一行。

我的两行代码回显了相同的字符串,但一个进入控制台,另一个进入日志文件。

echo "Starting scriptr" `date '+%T'`  >> script.log 
echo "Starting script" `date '+%T'`

谢谢

4

1 回答 1

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
于 2013-10-24T15:51:12.603 回答