Redirect stderr and stdout in Bash


Question

I want to redirect both stdout and stderr of a process to a single file. How do I do that in Bash?

1
625
6/2/2017 8:01:21 PM

Accepted Answer

Take a look here. Should be:

yourcommand &>filename

(redirects both stdout and stderr to filename).

714
10/7/2010 5:44:01 AM

do_something 2>&1 | tee -a some_file

This is going to redirect stderr to stdout and stdout to some_file and print it to stdout.


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon