Linux Command Output Redirection Rules
Dec. 24, 2013
Here's another thing that I learned today -- command output redirection syntax.
>
redirects the program's output to the specified file which is specified afterwards. If >
is preceded by ampersand, shell redirects all outputs (error and normal) to the file right of >
. If you don't specify ampersand, then only normal output is redirected.
In other words:
command &> file # redirect error and standard output to file
command > file # redirect standard output to file
command 2> file # redirect error output to file
This is how things work on Ubuntu and bash. Other shells could very well be different.