Enz*_*Chi 5 bash bash-scripting
我想要实现的是将正常消息和错误消息重定向到一个文件。还要将错误信息打印到控制台(只有错误信息)。
解决方案之一(众多)如下:
command 2>&1 1>logfile | tee -a logfile
Run Code Online (Sandbox Code Playgroud)
钥匙:
`2>&1` redirect the output of STDERR to STDOUT
`1>logfile` redirect STDOUT (note: leaves STDERR unchanged)
`| tee -a logfile` append the redirected STDERR to the logfile
Run Code Online (Sandbox Code Playgroud)
有关更多信息,请参阅Bash 黑客 Wiki
| 归档时间: |
|
| 查看次数: |
3373 次 |
| 最近记录: |