Redirect stdout and stderr to a file

From Redirect stdout & stderr and append to a file.

It is possible to redirect one output channel to another like “2>&1” which means “put the output of channel 2 (stderr) where right now channel 1 (stdout) goes” and let channel 1 point to a file:

process >>file 2>&1

But to be honest i would prefer you first solution with separately mentioned files for stdout and stderr anytime on weekdays and twice on sundays - it makes a much easier to maintain code AND it is not position dependent:

process >file 2>&1

will have stderr and stdout go to , but:

process 2>&1 >file

will have stdout go to and stderr to - screen! , because when the direction channel 2 should point to is evaluated channel 1 is still pointing to the terminal and not to the file.

Last modified: 10/11/2011 Tags: ,

This website is a personal resource. Nothing here is guaranteed correct or complete, so use at your own risk and try not to delete the Internet. -Stephan

Site Info

Privacy policy

Go to top