Redirection
From FreeBSDwiki
(Difference between revisions)
Line 1: | Line 1: | ||
− | + | '''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 | + | > sends output to a file (may include [[special files]] such as [[/dev/null]]) |
− | >> appends output | + | >> appends output to a file (without overwriting it) |
< sends output the other way | < sends output the other way | ||
<< appends output the other way | << appends output the other way | ||
Line 8: | Line 8: | ||
− | If you're using the [[bash]] shell | + | If you're using the [[bash]] or [[bourne shell|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. |
+ | |||
+ | [[Category:FreeBSD Terminology]] |
Revision as of 18:25, 30 August 2004
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.