Redirection (computing): Difference between revisions

Content deleted Content added
Tags: Mobile edit Mobile web edit
m Reverted edits by 174.255.199.173 (talk) to last version by 2001:DA8:201:3512:45E3:A23:2EB8:FE69
Line 10:
Redirection is usually implemented by placing certain [[token (parser)|characters]] between [[command (computing)|commands]].
 
===Basic===
Typically, the [[syntax]] of these characters is as follows, using <code>&lt;</code> to redirect input, and <code>&gt;</code> to redirect output. <syntaxhighlight lang="bash" inline>command1 > file1</syntaxhighlight> executes <tt>command1</tt>, placing the output in <tt>file1</tt>, as opposed to displaying it at the terminal, which is the usual destination for standard output. This will [[Clobbering|clobber]] any existing data in <tt>file1</tt>.
 
Using <syntaxhighlight lang="bash" inline>command1 < file1</syntaxhighlight> executes <tt>command1</tt>, with <tt>file1</tt> as the source of input, as opposed to the [[Computer keyboard|keyboard]], which is the usual source for standard input.
 
<syntaxhighlight lang="bash" inline>command1 < infile > outfile</syntaxhighlight> combines the two capabilities: <tt>command1</tt> reads from <tt>infile</tt> and writes to <tt>outfile</tt>
 
===Variants===