Open main menu

CDOT Wiki β

Changes

BASH Redirection

722 bytes added, 21:24, 15 September 2008
Cloning File Descriptors
This will use the three lines after the <code>mail</code> command and before the EOF line as the stdin to the <code>mail</code> command (i.e., the body of the e-mail message).
== Cloning Duplicating File Descriptors == The syntax <code>''a''>&''b''</code> can be used to redirect output for file descriptor ''a'' to file descriptor ''b''. This is commonly used to redirect stdout and stderr to the same location:  cal 16 2008 >all-output 2>&1 This redirects stdout to "all-output" and then sends stderr to the same location. Note that the order of redirection matters -- if the command was written in this way the result would be different:  cal 16 2008 2>&1 >all-output (In this case, stderr is redirected to the same place as stdout, which is the terminal, and then the stdout (alone) is redirected to the file "all-output"). A shortcut syntax permits stderr and stdout to be redirected to the same destination:  &>''filename''