Shell脚本输出到Console并登录到同一行?

时间:2013-10-24 15:48:17

标签: shell unix solaris

我是否可以将这两行shell脚本切成一行。

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

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

由于

1 个答案:

答案 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