如何既stdout和stderr重定向到一个文件 [英] How to redirect both stdout and stderr to a file

查看:565
本文介绍了如何既stdout和stderr重定向到一个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好我正在运行的命令的执行

Hi I am running a bash script that creates a log file for the execution of the command

我用下面的

Command1 >> log_file
Command2 >> log_file

这仅发送标准输出,而不是标准的错误出现在终端上。

This only sends the standard output and not the standard error which appears on the terminal.

我可以登录这两个标准错误和stdout记录到一个文件?

Can I log both the stderr and stdout logged to a file?

推荐答案

如果你想登录到同一文件:

If you want to log to the same file:

command1 >> log_file 2>&1

如果你想不同的文件:

command1 >> log_file 2>> err_file

这篇关于如何既stdout和stderr重定向到一个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆