Bash Output Redirection

I know that doing this:

foo 2>err.log > log

will capture the output to stderr and stdout.

I was just trying to redirect ALL the output to a single file. I thought this would work:

foo 2>&1 > log

But for some reason the stderr stuff was still being output to the console.

Luckily the top result in Google led me straight to the answer: To send all output to a file, use &>

foo &> log

One reply on “Bash Output Redirection”

How am I supposed to comment when I have no idea what you’re talking about.
(oh wait, I just did it. All I have to do is complain.)
Keep up the good work, Andy.

Comments are closed.