What does 2>/dev/null mean? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)What does outputting to /dev/null accomplish in bash scripts?What does /dev/null mean in a shell script?Disable all warnings for user (shell_exec)What is /dev/null?Get current ssh session's originating IP without being superuserexample of console output that is not written to standard outputStop output messages from cvlcsend logs to nowhereSaving command error log into text fileWhat does outputting to /dev/null accomplish in bash scripts?How to get line number from grep?what does 1>&5 mean?What does /dev/null mean in a shell script?What does grep line buffering do?Could someone explain what the following command does?What does “[[ $- != *i* ]] && return” mean?What does “ps -ef|grep processname” mean?How to insert a line break between stderr and stdoutturn off redirection to /dev/null

Classification of bundles, Postnikov towers, obstruction theory, local coefficients

Is above average number of years spent on PhD considered a red flag in future academia or industry positions?

When communicating altitude with a '9' in it, should it be pronounced "nine hundred" or "niner hundred"?

Why use gamma over alpha radiation?

Stop battery usage [Ubuntu 18]

What's the point in a preamp?

Can I throw a sword that doesn't have the Thrown property at someone?

Problem when applying foreach loop

Mortgage adviser recommends a longer term than necessary combined with overpayments

Working around an AWS network ACL rule limit

Why is "Captain Marvel" translated as male in Portugal?

What to do with post with dry rot?

How should I respond to a player wanting to catch a sword between their hands?

How does modal jazz use chord progressions?

What is the largest species of polychaete?

Single author papers against my advisor's will?

How to say that you spent the night with someone, you were only sleeping and nothing else?

Interesting examples of non-locally compact topological groups

The following signatures were invalid: EXPKEYSIG 1397BC53640DB551

Can a zero nonce be safely used with AES-GCM if the key is random and never used again?

What was the last x86 CPU that did not have the x87 floating-point unit built in?

Can a monk deflect thrown melee weapons?

How to politely respond to generic emails requesting a PhD/job in my lab? Without wasting too much time

Array/tabular for long multiplication



What does 2>/dev/null mean?



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)What does outputting to /dev/null accomplish in bash scripts?What does /dev/null mean in a shell script?Disable all warnings for user (shell_exec)What is /dev/null?Get current ssh session's originating IP without being superuserexample of console output that is not written to standard outputStop output messages from cvlcsend logs to nowhereSaving command error log into text fileWhat does outputting to /dev/null accomplish in bash scripts?How to get line number from grep?what does 1>&5 mean?What does /dev/null mean in a shell script?What does grep line buffering do?Could someone explain what the following command does?What does “[[ $- != *i* ]] && return” mean?What does “ps -ef|grep processname” mean?How to insert a line break between stderr and stdoutturn off redirection to /dev/null



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








196















I would like a brief explanation of the following command line:



grep -i 'abc' content 2>/dev/null 









share|improve this question






























    196















    I would like a brief explanation of the following command line:



    grep -i 'abc' content 2>/dev/null 









    share|improve this question


























      196












      196








      196


      100






      I would like a brief explanation of the following command line:



      grep -i 'abc' content 2>/dev/null 









      share|improve this question
















      I would like a brief explanation of the following command line:



      grep -i 'abc' content 2>/dev/null 






      command-line grep redirect stdout






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Sep 6 '18 at 12:54









      Zanna

      51.4k13140243




      51.4k13140243










      asked Sep 26 '13 at 8:21









      NaiveNaive

      1,48991830




      1,48991830




















          3 Answers
          3






          active

          oldest

          votes


















          286














          The > operator redirects the output usually to a file but it can be to a device. You can also use >> to append.



          If you don't specify a number then the standard output stream is assumed but you can also redirect errors



          > file redirects stdout to file
          1> file redirects stdout to file
          2> file redirects stderr to file
          &> file redirects stdout and stderr to file



          /dev/null is the null device it takes any input you want and throws it away. It can be used to suppress any output.






          share|improve this answer




















          • 3





            is there a difference between > /dev/null 2>&1 and &> /dev/null

            – Alexander Mills
            Oct 19 '17 at 0:25






          • 9





            In practice today I don't think there is 2>&1 is an older syntax so &> would not have worked years ago but both are equivalent.

            – Warren Hill
            Oct 19 '17 at 2:47


















          19














          In short, it redirects stderr (fd 2) to the black hole (discards the output of the command).



          Some more common use cases for redirection:



          command > /dev/null 2>&1 &


          Run command in the background, discard stdout and stderr



          command >> /path/to/log 2>&1 &


          Run command and append stdout and stderr to a log file.






          share|improve this answer




















          • 3





            Is there a good reason to use > /dev/null 2>&1 instead of &> /dev/null?

            – Craig McQueen
            Nov 30 '15 at 6:43






          • 7





            @CraigMcQueen &> is new in Bash 4, the former is just the traditional way, I am just so used to it (easy to remember).

            – Terry Wang
            Nov 30 '15 at 12:24












          • @CraigMcQueen according to a comment on this answer, &> /dev/null may not work in some shells but > /dev/null 2>&1 will work in all POSIX compatible shells.

            – Stack Underflow
            Jan 6 at 23:41







          • 1





            Why is it 2>&1 and not 2&1> ??

            – marienbad
            Mar 11 at 21:30


















          8














          /dev/null is treated as black hole in Linux/Unix, so you can put anything into this but you will not be able to get it back from /dev/null.



          Further, 2> means that you are redirecting (i.e. >) the stderr (i.e. 2) into the black hole (i.e. /dev/null)



          Your command is:



          grep -i 'abc' content 2>/dev/null 


          Don't try to end with another forward slash like this - 2>/dev/null/ (it's not a directory).






          share|improve this answer

























            Your Answer








            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "89"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f350208%2fwhat-does-2-dev-null-mean%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            3 Answers
            3






            active

            oldest

            votes








            3 Answers
            3






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            286














            The > operator redirects the output usually to a file but it can be to a device. You can also use >> to append.



            If you don't specify a number then the standard output stream is assumed but you can also redirect errors



            > file redirects stdout to file
            1> file redirects stdout to file
            2> file redirects stderr to file
            &> file redirects stdout and stderr to file



            /dev/null is the null device it takes any input you want and throws it away. It can be used to suppress any output.






            share|improve this answer




















            • 3





              is there a difference between > /dev/null 2>&1 and &> /dev/null

              – Alexander Mills
              Oct 19 '17 at 0:25






            • 9





              In practice today I don't think there is 2>&1 is an older syntax so &> would not have worked years ago but both are equivalent.

              – Warren Hill
              Oct 19 '17 at 2:47















            286














            The > operator redirects the output usually to a file but it can be to a device. You can also use >> to append.



            If you don't specify a number then the standard output stream is assumed but you can also redirect errors



            > file redirects stdout to file
            1> file redirects stdout to file
            2> file redirects stderr to file
            &> file redirects stdout and stderr to file



            /dev/null is the null device it takes any input you want and throws it away. It can be used to suppress any output.






            share|improve this answer




















            • 3





              is there a difference between > /dev/null 2>&1 and &> /dev/null

              – Alexander Mills
              Oct 19 '17 at 0:25






            • 9





              In practice today I don't think there is 2>&1 is an older syntax so &> would not have worked years ago but both are equivalent.

              – Warren Hill
              Oct 19 '17 at 2:47













            286












            286








            286







            The > operator redirects the output usually to a file but it can be to a device. You can also use >> to append.



            If you don't specify a number then the standard output stream is assumed but you can also redirect errors



            > file redirects stdout to file
            1> file redirects stdout to file
            2> file redirects stderr to file
            &> file redirects stdout and stderr to file



            /dev/null is the null device it takes any input you want and throws it away. It can be used to suppress any output.






            share|improve this answer















            The > operator redirects the output usually to a file but it can be to a device. You can also use >> to append.



            If you don't specify a number then the standard output stream is assumed but you can also redirect errors



            > file redirects stdout to file
            1> file redirects stdout to file
            2> file redirects stderr to file
            &> file redirects stdout and stderr to file



            /dev/null is the null device it takes any input you want and throws it away. It can be used to suppress any output.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Sep 26 '13 at 13:55

























            answered Sep 26 '13 at 8:38









            Warren HillWarren Hill

            16.1k165477




            16.1k165477







            • 3





              is there a difference between > /dev/null 2>&1 and &> /dev/null

              – Alexander Mills
              Oct 19 '17 at 0:25






            • 9





              In practice today I don't think there is 2>&1 is an older syntax so &> would not have worked years ago but both are equivalent.

              – Warren Hill
              Oct 19 '17 at 2:47












            • 3





              is there a difference between > /dev/null 2>&1 and &> /dev/null

              – Alexander Mills
              Oct 19 '17 at 0:25






            • 9





              In practice today I don't think there is 2>&1 is an older syntax so &> would not have worked years ago but both are equivalent.

              – Warren Hill
              Oct 19 '17 at 2:47







            3




            3





            is there a difference between > /dev/null 2>&1 and &> /dev/null

            – Alexander Mills
            Oct 19 '17 at 0:25





            is there a difference between > /dev/null 2>&1 and &> /dev/null

            – Alexander Mills
            Oct 19 '17 at 0:25




            9




            9





            In practice today I don't think there is 2>&1 is an older syntax so &> would not have worked years ago but both are equivalent.

            – Warren Hill
            Oct 19 '17 at 2:47





            In practice today I don't think there is 2>&1 is an older syntax so &> would not have worked years ago but both are equivalent.

            – Warren Hill
            Oct 19 '17 at 2:47













            19














            In short, it redirects stderr (fd 2) to the black hole (discards the output of the command).



            Some more common use cases for redirection:



            command > /dev/null 2>&1 &


            Run command in the background, discard stdout and stderr



            command >> /path/to/log 2>&1 &


            Run command and append stdout and stderr to a log file.






            share|improve this answer




















            • 3





              Is there a good reason to use > /dev/null 2>&1 instead of &> /dev/null?

              – Craig McQueen
              Nov 30 '15 at 6:43






            • 7





              @CraigMcQueen &> is new in Bash 4, the former is just the traditional way, I am just so used to it (easy to remember).

              – Terry Wang
              Nov 30 '15 at 12:24












            • @CraigMcQueen according to a comment on this answer, &> /dev/null may not work in some shells but > /dev/null 2>&1 will work in all POSIX compatible shells.

              – Stack Underflow
              Jan 6 at 23:41







            • 1





              Why is it 2>&1 and not 2&1> ??

              – marienbad
              Mar 11 at 21:30















            19














            In short, it redirects stderr (fd 2) to the black hole (discards the output of the command).



            Some more common use cases for redirection:



            command > /dev/null 2>&1 &


            Run command in the background, discard stdout and stderr



            command >> /path/to/log 2>&1 &


            Run command and append stdout and stderr to a log file.






            share|improve this answer




















            • 3





              Is there a good reason to use > /dev/null 2>&1 instead of &> /dev/null?

              – Craig McQueen
              Nov 30 '15 at 6:43






            • 7





              @CraigMcQueen &> is new in Bash 4, the former is just the traditional way, I am just so used to it (easy to remember).

              – Terry Wang
              Nov 30 '15 at 12:24












            • @CraigMcQueen according to a comment on this answer, &> /dev/null may not work in some shells but > /dev/null 2>&1 will work in all POSIX compatible shells.

              – Stack Underflow
              Jan 6 at 23:41







            • 1





              Why is it 2>&1 and not 2&1> ??

              – marienbad
              Mar 11 at 21:30













            19












            19








            19







            In short, it redirects stderr (fd 2) to the black hole (discards the output of the command).



            Some more common use cases for redirection:



            command > /dev/null 2>&1 &


            Run command in the background, discard stdout and stderr



            command >> /path/to/log 2>&1 &


            Run command and append stdout and stderr to a log file.






            share|improve this answer















            In short, it redirects stderr (fd 2) to the black hole (discards the output of the command).



            Some more common use cases for redirection:



            command > /dev/null 2>&1 &


            Run command in the background, discard stdout and stderr



            command >> /path/to/log 2>&1 &


            Run command and append stdout and stderr to a log file.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Sep 6 '18 at 12:57









            Zanna

            51.4k13140243




            51.4k13140243










            answered Sep 26 '13 at 8:32









            Terry WangTerry Wang

            6,53932224




            6,53932224







            • 3





              Is there a good reason to use > /dev/null 2>&1 instead of &> /dev/null?

              – Craig McQueen
              Nov 30 '15 at 6:43






            • 7





              @CraigMcQueen &> is new in Bash 4, the former is just the traditional way, I am just so used to it (easy to remember).

              – Terry Wang
              Nov 30 '15 at 12:24












            • @CraigMcQueen according to a comment on this answer, &> /dev/null may not work in some shells but > /dev/null 2>&1 will work in all POSIX compatible shells.

              – Stack Underflow
              Jan 6 at 23:41







            • 1





              Why is it 2>&1 and not 2&1> ??

              – marienbad
              Mar 11 at 21:30












            • 3





              Is there a good reason to use > /dev/null 2>&1 instead of &> /dev/null?

              – Craig McQueen
              Nov 30 '15 at 6:43






            • 7





              @CraigMcQueen &> is new in Bash 4, the former is just the traditional way, I am just so used to it (easy to remember).

              – Terry Wang
              Nov 30 '15 at 12:24












            • @CraigMcQueen according to a comment on this answer, &> /dev/null may not work in some shells but > /dev/null 2>&1 will work in all POSIX compatible shells.

              – Stack Underflow
              Jan 6 at 23:41







            • 1





              Why is it 2>&1 and not 2&1> ??

              – marienbad
              Mar 11 at 21:30







            3




            3





            Is there a good reason to use > /dev/null 2>&1 instead of &> /dev/null?

            – Craig McQueen
            Nov 30 '15 at 6:43





            Is there a good reason to use > /dev/null 2>&1 instead of &> /dev/null?

            – Craig McQueen
            Nov 30 '15 at 6:43




            7




            7





            @CraigMcQueen &> is new in Bash 4, the former is just the traditional way, I am just so used to it (easy to remember).

            – Terry Wang
            Nov 30 '15 at 12:24






            @CraigMcQueen &> is new in Bash 4, the former is just the traditional way, I am just so used to it (easy to remember).

            – Terry Wang
            Nov 30 '15 at 12:24














            @CraigMcQueen according to a comment on this answer, &> /dev/null may not work in some shells but > /dev/null 2>&1 will work in all POSIX compatible shells.

            – Stack Underflow
            Jan 6 at 23:41






            @CraigMcQueen according to a comment on this answer, &> /dev/null may not work in some shells but > /dev/null 2>&1 will work in all POSIX compatible shells.

            – Stack Underflow
            Jan 6 at 23:41





            1




            1





            Why is it 2>&1 and not 2&1> ??

            – marienbad
            Mar 11 at 21:30





            Why is it 2>&1 and not 2&1> ??

            – marienbad
            Mar 11 at 21:30











            8














            /dev/null is treated as black hole in Linux/Unix, so you can put anything into this but you will not be able to get it back from /dev/null.



            Further, 2> means that you are redirecting (i.e. >) the stderr (i.e. 2) into the black hole (i.e. /dev/null)



            Your command is:



            grep -i 'abc' content 2>/dev/null 


            Don't try to end with another forward slash like this - 2>/dev/null/ (it's not a directory).






            share|improve this answer





























              8














              /dev/null is treated as black hole in Linux/Unix, so you can put anything into this but you will not be able to get it back from /dev/null.



              Further, 2> means that you are redirecting (i.e. >) the stderr (i.e. 2) into the black hole (i.e. /dev/null)



              Your command is:



              grep -i 'abc' content 2>/dev/null 


              Don't try to end with another forward slash like this - 2>/dev/null/ (it's not a directory).






              share|improve this answer



























                8












                8








                8







                /dev/null is treated as black hole in Linux/Unix, so you can put anything into this but you will not be able to get it back from /dev/null.



                Further, 2> means that you are redirecting (i.e. >) the stderr (i.e. 2) into the black hole (i.e. /dev/null)



                Your command is:



                grep -i 'abc' content 2>/dev/null 


                Don't try to end with another forward slash like this - 2>/dev/null/ (it's not a directory).






                share|improve this answer















                /dev/null is treated as black hole in Linux/Unix, so you can put anything into this but you will not be able to get it back from /dev/null.



                Further, 2> means that you are redirecting (i.e. >) the stderr (i.e. 2) into the black hole (i.e. /dev/null)



                Your command is:



                grep -i 'abc' content 2>/dev/null 


                Don't try to end with another forward slash like this - 2>/dev/null/ (it's not a directory).







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Sep 13 '18 at 6:51









                Zanna

                51.4k13140243




                51.4k13140243










                answered Jun 11 '15 at 10:57









                Indrajeet GourIndrajeet Gour

                18114




                18114



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Ask Ubuntu!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f350208%2fwhat-does-2-dev-null-mean%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Tamil (spriik) Luke uk diar | Nawigatjuun

                    Align equal signs while including text over equalitiesAMS align: left aligned text/math plus multicolumn alignmentMultiple alignmentsAligning equations in multiple placesNumbering and aligning an equation with multiple columnsHow to align one equation with another multline equationUsing \ in environments inside the begintabularxNumber equations and preserving alignment of equal signsHow can I align equations to the left and to the right?Double equation alignment problem within align enviromentAligned within align: Why are they right-aligned?

                    Where does the image of a data connector as a sharp metal spike originate from?Where does the concept of infected people turning into zombies only after death originate from?Where does the motif of a reanimated human head originate?Where did the notion that Dragons could speak originate?Where does the archetypal image of the 'Grey' alien come from?Where did the suffix '-Man' originate?Where does the notion of being injured or killed by an illusion originate?Where did the term “sophont” originate?Where does the trope of magic spells being driven by advanced technology originate from?Where did the term “the living impaired” originate?