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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With