我能不能把这两行shell脚本剪成一行。
我的两行代码回显相同的字符串,但一行进入控制台,另一行进入日志文件。
echo "Starting scriptr" `date '+%T'` >> script.log
echo "Starting script" `date '+%T'`
谢谢
最佳答案
使用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
关于Shell 脚本输出到控制台和登录在同一行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19570627/