<?xml version="1.0" encoding="ISO-8859-1"?><html xmlns="http://www.w3.org/1999/xhtml" xmlns:xh="http://www.w3.org/1999/xhtml" xmlns:axle="http://www.cs.odu.edu/~zeil/axle" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ns0="http://www.cs.odu.edu/~zeil/axle" mode="ignore" id="redirect" ns0:xlinkuri="open/redirection.dbk" ns0:xpath="//*[@id='redirect']" ns0:page="redirection" foo="0 " ns0:last="/cocoon/~cs252/open/redirection/piping.html"><head><title>Redirection and Pipes</title><link type="text/css" href="_axle/docbookstyle.css" rel="stylesheet"/><link type="text/css" href="_axle/cppformat.css" rel="stylesheet"/><link type="text/css" href="_axle/overrides.css" rel="stylesheet"/><script src="_axle/docbook.js"/><link href="http://cocoon.cs.odu.edu:80/cocoon/~cs252/open/redirection/redirect.html" title="Next" rel="next"/><link href="http://cocoon.cs.odu.edu:80/cocoon/~cs252/open/redirection/piping.html" title="Last" rel="last"/><script>function gotoNext() {top.location.href="/cocoon/~cs252/open/redirection/redirect.html";}
function gotoPrev() {}
function gotoUp() {}
</script><xhtml:link xmlns:xhtml="http://www.w3.org/1999/xhtml" rel="stylesheet" href="_axle/navigation.css" type="text/css"/><xhtml:script xmlns:xhtml="http://www.w3.org/1999/xhtml" src="_axle/navigation.js"/></head><body><table width="100%" class="navigationBar"><tr class="navigationBar"><td width="5%" class="navigationBar"><a class="navigationBarArrow" title="Next" href="http://cocoon.cs.odu.edu:80/cocoon/~cs252/open/redirection/redirect.html"><img class="navigationBar" src="_axle/next.gif" alt="Next"/></a></td><td width="5%" class="navigationBar"><a class="navigationBarArrow" title="Last" href="http://cocoon.cs.odu.edu:80/cocoon/~cs252/open/redirection/piping.html"><img class="navigationBar" src="_axle/last.gif" alt="Last"/></a></td><td class="navigationBar"/><td width="5%" class="navigationBar"><a class="navigationBar" title="CS252 Home" href="http://cocoon.cs.odu.edu:80/cocoon/~cs252/directory/announcements.html"><img class="navigationBar" src="_axle/home.gif" alt="CS252 Home"/></a></td><td width="5%" class="navigationBar"><a class="navigationBar" title="discuss this page" href="http://cocoon.cs.odu.edu:80/cocoon/~cs252/forum/getXPath/open/redirection/redirection.html"><img class="navigationBar" src="_axle/forum.gif" alt="discuss this page"/></a></td></tr></table><br/><div class="info_article"><div class="title_article">Redirection and Pipes</div><div class="author_article"><span class="firstname">Steven</span> <span class="othername" role="mi">J</span> <span class="surname">Zeil</span></div><div class="affiliation">
        <span class="orgname">Old Dominion University</span>
        <span class="orgdiv">Dept. of Computer Science</span>
      </div><table width="100%"><tr><td align="left"><span class="copyright">©<span class="year">2000-2006</span> <span class="holder">Steven J. Zeil, Old Dominion University</span></span></td><td/><td align="right"><span class="date">May. 26, 2006</span></td></tr></table></div><div class="TOC">Contents:<div class="TOC-section0"><a href="redirection.html#redirect">1 Redirection</a></div><div class="TOC-section0"><a href="piping.html#piping">2 Pipes</a></div></div>
  
  <div class="epigraph">
    <p class="para" align="center">
              (A printable version of this document is available 
              <a url="allPages.html" href="allPages.html">here</a>.)
            </p>
  </div>
  <p class="para">One of the interesting ideas that pervades Unix is that many, if not
most, programs can be viewed as <span class="quote">
      &#8220;filters&#8221;
    </span> or <span class="quote">
      &#8220;transforms&#8221;
    </span> that
take a stream of text as input and produce an altered stream of text
as output. Many Unix commands are designed to perform relatively
trivial tasks, perhaps not very useful by themselves, that can be
chained together in interesting and useful ways.</p>
  <p class="para">The practical consequence of this is that Unix shells devote special
attention to a <span class="firstterm">standard input</span> stream that forms the main input
to most programs/commands, and to a <span class="firstterm">standard output</span> stream that
forms the main output from most programs/commands.<a onmouseover="DBshowBriefly('fn_fref1_live')" name="fn_fref1" id="fn_fref1" class="footnotemark" href="piping.html#fn_fnote1">1</a><div class="footnote_live" id="fn_fref1_live">There is
actually a second output stream supported by many programs, the <span class="firstterm">standard error</span> stream, used for writing error/debugging messages.</div>
The shell attempts to make it easy either to <span class="firstterm">redirect</span> one of
these standard streams to a file or to <span class="firstterm">pipe</span> the standard output
stream of one program into the standard input of another.</p>
  <script type="text/javascript">
checkForAnchorOnOtherPage('redirect','redirect');
</script>
  <script type="text/javascript">
checkForAnchorOnOtherPage('piping','piping');
</script>
<script type="text/javascript">
checkForAnchorOnOtherPage('fn_fnote1','piping');
</script><br/><table width="100%" class="navigationBar"><tr class="navigationBar"><td width="5%" class="navigationBar"><a class="navigationBarArrow" title="Next" href="http://cocoon.cs.odu.edu:80/cocoon/~cs252/open/redirection/redirect.html"><img class="navigationBar" src="_axle/next.gif" alt="Next"/></a></td><td width="5%" class="navigationBar"><a class="navigationBarArrow" title="Last" href="http://cocoon.cs.odu.edu:80/cocoon/~cs252/open/redirection/piping.html"><img class="navigationBar" src="_axle/last.gif" alt="Last"/></a></td><td class="navigationBar"/><td width="5%" class="navigationBar"><a class="navigationBar" title="CS252 Home" href="http://cocoon.cs.odu.edu:80/cocoon/~cs252/directory/announcements.html"><img class="navigationBar" src="_axle/home.gif" alt="CS252 Home"/></a></td><td width="5%" class="navigationBar"><a class="navigationBar" title="discuss this page" href="http://cocoon.cs.odu.edu:80/cocoon/~cs252/forum/getXPath/open/redirection/redirection.html"><img class="navigationBar" src="_axle/forum.gif" alt="discuss this page"/></a></td></tr></table></body></html>