[英]Print STDOUT/STDERR and write them to a file in Bash?
有没有办法让Bash将STDOUT / STDERR重定向到一个文件,但仍然将它们打印到终端?
This will redirect both STDOUT and STDERR to the same file: 这会将STDOUT和STDERR重定向到同一个文件:
some_command 2>&1 | tee file.log
$ touch foo; ls foo asfdsafsadf 2>&1 | tee file.log
ls: asfdsafsadf: No such file or directory
foo
$ cat file.log
ls: asfdsafsadf: No such file or directory
foo
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.