Following would redirect the Stdout and Stderr to logfile
:
$ command &> logfile
How do I do this redirection without overwrite logfile
开发者_运维知识库during next run of command
. Something like >>
if it was a plain redirection.
You could attach stderr (2) to stdout (1) and then redirect stdout in append-mode:
command >> logfile 2>&1
The 2>&1
bit attaches stderr to stdout and then you redirect stdout to append to logfile
in the usual manner.
From the BASH manual
The format for appending standard output and standard error is: &>>word This is semantically equivalent to >>word 2>&1
So, $ command &>> logfile
.
EDIT: The shorthand version seems to be a feature in bash version 4, so for compability reasons you should use command >> logfile 2>&1
.
According to the documentation, what you're after is what you may have guessed:
$ command &>> logfile
Notice the doubled >>
to append.
You answered your question in your question....
$ command &>> logfile
精彩评论