Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect stderr and stdout in Bash [duplicate]

I want to redirect both standard output and standard error of a process to a single file. How do I do that in Bash?

like image 813
flybywire Avatar asked Mar 12 '09 09:03

flybywire


People also ask

How can I redirect stdout and stderr to same file?

Understanding the concept of redirections and file descriptors is very important when working on the command line. To redirect stderr and stdout , use the 2>&1 or &> constructs.

What is the meaning of 2 >& 1?

1 "Standard output" output file descriptor. The expression 2>&1 copies file descriptor 1 to location 2 , so any output written to 2 ("standard error") in the execution environment goes to the same file originally described by 1 ("standard output").


1 Answers

Take a look here. It should be:

yourcommand &> filename 

It redirects both standard output and standard error to file filename.

like image 58
dirkgently Avatar answered Sep 20 '22 13:09

dirkgently