pavement

Redirection

From FreeBSDwiki
(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
Sending one form of output to a form of input other than that which it was originally intended. Common operands include: '''>''', '''>>''', '''<''', '''<<''', and the ever popular '''|'''.
+
'''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 somewhere (usually a file)
+
  >  sends output to a file (may include [[special files]] such as [[/dev/null]])
  >> appends output somewhere (without overwriting it)
+
  >> 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, because you're not a sadist and like useful shells, you also have some special options available to you: you can redirect standard input, standard output and standard error messages.
+
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 19: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.

Personal tools