Bash redirectionEdit
man bash
has a wealth of information on redirection (grep for REDIRECTION
) but here is a quick cheat sheet:
Redirect nothing
$ command
Redirect standard out
$ command > target
Redirect standard error
$ command 2> target
Redirect standard error and standard out
$ command > target &2>1
$ command
$ command > target
Redirect standard error
$ command 2> target
Redirect standard error and standard out
$ command > target &2>1
$ command 2> target
$ command > target &2>1
Or, as short-hand:
$ command &> target
Redirecting to a command rather than a file or device:
$ command 2>&1 | mail username@localhost
Redirecting and displaying, using tee
:
$ command 2>&1 | tee target
Appending rather than clobbering:
$ command >> target &2>1