Posted By: Anonymous
To redirect stdout to a truncated file in Bash, I know to use:
cmd > file.txt
To redirect stdout in Bash, appending to a file, I know to use:
cmd >> file.txt
To redirect both stdout and stderr to a truncated file, I know to use:
cmd &> file.txt
How do I redirect both stdout and stderr appending to a file?
cmd &>> file.txt did not work for me.
cmd >>file.txt 2>&1
Bash executes the redirects from left to right as follows:
file.txtin append mode and redirect
stdoutis currently going”. In this case, that is a file opened in append mode. In other words, the
&1reuses the file descriptor which