pavement

Redirection

From FreeBSDwiki
Revision as of 19:25, 30 August 2004 by Jimbo (Talk | contribs)
Jump to: navigation, search

Redirection is sending the output of a program to somewhere other than where it would otherwise go - for example you can redirect the output of an ls command to a text file for later processing or to the grep command for filtering. Common operands include: >, >>, <, <<, and the ever popular |.

>  sends output to a file (may include special files such as /dev/null)
>> appends output to a file (without overwriting it)
<  sends output the other way
<< appends output the other way
|  sends output to a program (frequently, a system command like grep)


If you're using the bash or bourne shells, you also have some special options available to you: you can redirect standard input, standard output and standard error messages. Other shells such as csh are notably limited in redirection capability, making them better suited to interactive use than to shell programming or other complex uses.

Personal tools