Gnuru.org
Adventures in Linux


Bash Command Output Redirection
11 March 2007 @ 19:02 GMT
by Paul


One thing that I can never remember in Bash is redirecting output. This is particularly important if a command, say a test script, is outputting all sorts of information and you need it in a file to examine later.

To redirect STDOUT to a file use '>':

somecommand > file

Of course the normal output is all very well, but usually it is the errors that are more important. To redirect STDERR to a file use 2>

somecommand 2> file

To capture both STDOUT and STDERR use '&>'

somecommand &> file


Leave a comment:

Are you human?