Search This Blog

Sunday, January 23, 2011

Command Input and Output Redirection Operators


Operation  Bash Shell 
 Redirection Syntax
Read standard input from a file.  command
Read standard input until end of marker.  command <
Write standard output to a file.  command >file
Append standard output to end of file.  command >>file
Write standard output and standard error to separate files.  command >file 2>file2
Write standard output and standard error to the same file.  command >file 2>&1
Write standard output and standard error to the same file.  command &> file
Append standard output and standard error to the end of a file.  command >>file 2>&1
Send (pipe) standard output of first command to input of second command. command | command2
Send (pipe) standard output and standard error to input of second command. command 2>&1 | command2
Related Posts with Thumbnails