<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: &amp;gt;/dev/null 2&amp;gt;&amp;amp;1 in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/gt-dev-null-2-gt-amp-1/m-p/4061485#M29835</link>
    <description>Chris,&lt;BR /&gt;&lt;BR /&gt;in UNIX &lt;BR /&gt;0 = stdin&lt;BR /&gt;1 = stdout&lt;BR /&gt;2 = stderr&lt;BR /&gt;&lt;BR /&gt;&amp;gt;/dev/null 2&amp;gt;&amp;amp;1 means&lt;BR /&gt;redirect all the standard out and standard error messages/output/results from the programs/scripts to /dev/null ( which means they go to a bottomless pit)</description>
    <pubDate>Wed, 29 Aug 2007 10:06:37 GMT</pubDate>
    <dc:creator>Basheer_2</dc:creator>
    <dc:date>2007-08-29T10:06:37Z</dc:date>
    <item>
      <title>&gt;/dev/null 2&gt;&amp;1</title>
      <link>https://community.hpe.com/t5/operating-system-linux/gt-dev-null-2-gt-amp-1/m-p/4061483#M29833</link>
      <description>hi&lt;BR /&gt;&lt;BR /&gt;what does it mean &lt;BR /&gt;&lt;BR /&gt;&amp;gt;/dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;&lt;BR /&gt;on the end of the cron job ?&lt;BR /&gt;&lt;BR /&gt;kind regards&lt;BR /&gt;chris</description>
      <pubDate>Tue, 28 Aug 2007 05:22:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/gt-dev-null-2-gt-amp-1/m-p/4061483#M29833</guid>
      <dc:creator>'chris'</dc:creator>
      <dc:date>2007-08-28T05:22:59Z</dc:date>
    </item>
    <item>
      <title>Re: &gt;/dev/null 2&gt;&amp;1</title>
      <link>https://community.hpe.com/t5/operating-system-linux/gt-dev-null-2-gt-amp-1/m-p/4061484#M29834</link>
      <description>Ok, we'll need to talk a little bit about pipes and file handles to make sure this all makes sense in the long run.&lt;BR /&gt;&lt;BR /&gt;First off, I'll give you the short answer:&lt;BR /&gt;&lt;BR /&gt;Send any output to the bin, so you don't see it.&lt;BR /&gt;&lt;BR /&gt;Now, we'll go into it a bit further, so you'll know what some of the funkie's mean.&lt;BR /&gt;&lt;BR /&gt;When in a shell, you can do various things with the output and input to commands.  You can run them through a pipe:&lt;BR /&gt;&lt;BR /&gt;grep root /var/log/messages | less&lt;BR /&gt;&lt;BR /&gt;This takes the output of the 'grep' commands, and uses the 'less' paginator to finally display it on the screen.&lt;BR /&gt;&lt;BR /&gt;To go into further detail, this sends the STDOUT of 'grep' to less.&lt;BR /&gt;&lt;BR /&gt;If you wanted to send the output to a file, you'd use a redirect:&lt;BR /&gt;&lt;BR /&gt;grep root /var/log/messages &amp;gt; /tmp/file&lt;BR /&gt;&lt;BR /&gt;This takes the STDOUT, and sticks it into '/tmp/file'.  I won't go into detail about the &amp;gt; and &amp;gt;&amp;gt; options etc. as they are all covered in the man page.&lt;BR /&gt;&lt;BR /&gt;There are 3 file descriptors for every process.  STDIN, STDOUT and STDERR.  These map to 0, 1 and 2 respecitvly.&lt;BR /&gt;&lt;BR /&gt;Strangely enough, the above command can also be written as:&lt;BR /&gt;&lt;BR /&gt;grep root /var/log/messages 1&amp;gt; /tmp/file&lt;BR /&gt;&lt;BR /&gt;The first command makes the assumption that you want to redirect STDOUT.  This one clears up that assumption.&lt;BR /&gt;&lt;BR /&gt;Now we'll look at STDERR:&lt;BR /&gt;&lt;BR /&gt;grep root /var/log/mseeagse &amp;gt; /tmp/file&lt;BR /&gt;&lt;BR /&gt;This will spit out an error to your tty, even though you've redirected the output.&lt;BR /&gt;&lt;BR /&gt;grep root /var/log/mseeagse 2&amp;gt; /tmp/file&lt;BR /&gt;&lt;BR /&gt;This one will output nothing, and '/tmp/file' will contain the error.  If we didn't miss-spell the messages file name, any errors that might occur would go to the file, but the output will go to the TTY.&lt;BR /&gt;&lt;BR /&gt;Now we'll do the last confusing thing, moving a file descriptor to a different one.  This is where the &amp;amp;&lt;NUMBER&gt; comes in:&lt;BR /&gt;&lt;BR /&gt;grep root /var/log/mseeagse 2&amp;gt; &amp;amp;1&lt;BR /&gt;&lt;BR /&gt;This moves STDERR so it comes out in the same place as STDOUT.  It says "Move file descriptor 2 to file descriptor 1".&lt;BR /&gt;&lt;BR /&gt;Thus where we get to your tail.  We mix and match the STDOUT and STDERR redirections:&lt;BR /&gt;&lt;BR /&gt;grep root /var/log/messages &amp;gt; /tmp/file 2&amp;gt; &amp;amp;1&lt;BR /&gt;grep root /var/log/mseeagse &amp;gt; /tmp/file 2&amp;gt; &amp;amp;1&lt;BR /&gt;&lt;BR /&gt;With both of these commands, both the regular output (STDOUT), and any errors that occur (STDERR) will go into '/tmp/file'.&lt;BR /&gt;&lt;BR /&gt;When stacking redirects like this, there is one major thing to be aware of.  When you move a file descriptor, you have to make sure the descriptor you are moving too has already been redirected to where you want, otherwise you can get some... interesting results.&lt;/NUMBER&gt;</description>
      <pubDate>Tue, 28 Aug 2007 06:11:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/gt-dev-null-2-gt-amp-1/m-p/4061484#M29834</guid>
      <dc:creator>Stuart Browne</dc:creator>
      <dc:date>2007-08-28T06:11:15Z</dc:date>
    </item>
    <item>
      <title>Re: &gt;/dev/null 2&gt;&amp;1</title>
      <link>https://community.hpe.com/t5/operating-system-linux/gt-dev-null-2-gt-amp-1/m-p/4061485#M29835</link>
      <description>Chris,&lt;BR /&gt;&lt;BR /&gt;in UNIX &lt;BR /&gt;0 = stdin&lt;BR /&gt;1 = stdout&lt;BR /&gt;2 = stderr&lt;BR /&gt;&lt;BR /&gt;&amp;gt;/dev/null 2&amp;gt;&amp;amp;1 means&lt;BR /&gt;redirect all the standard out and standard error messages/output/results from the programs/scripts to /dev/null ( which means they go to a bottomless pit)</description>
      <pubDate>Wed, 29 Aug 2007 10:06:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/gt-dev-null-2-gt-amp-1/m-p/4061485#M29835</guid>
      <dc:creator>Basheer_2</dc:creator>
      <dc:date>2007-08-29T10:06:37Z</dc:date>
    </item>
  </channel>
</rss>

