tom*_*ato 2 unix shell solaris
我能不能把这两行shell脚本剪成一行。
我的两行代码回显相同的字符串,但一行进入控制台,另一行进入日志文件。
echo "Starting scriptr" `date '+%T'` >> script.log
echo "Starting script" `date '+%T'`
Run Code Online (Sandbox Code Playgroud)
谢谢
使用tee:
echo "Starting scriptr" `date '+%T'` | tee script.log
Run Code Online (Sandbox Code Playgroud)
为了附加到日志文件,请说tee -a
引用自man tee:
tee - read from standard input and write to standard output and files
Run Code Online (Sandbox Code Playgroud)