How to write dd status/result message to a file?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












I use this dd command for checking disk speed:



dd if=/dev/zero of=/path/file bs=1G count=1 oflag=direct


which gives back something like this:



1 oflag=direct
1+0 records in
1+0 records out
1073741824 bytes (1,1 GB, 1,0 GiB) copied, 8,52315 s, 126 MB/s


Now I would like to pipe this output, not the file dd is writing, but to a separate file.



I tried adding



>> /tmp/foo


or



| sudo tee /tmp/foo


to the dd command, but that just creates an empty file.







share|improve this question


























    up vote
    1
    down vote

    favorite












    I use this dd command for checking disk speed:



    dd if=/dev/zero of=/path/file bs=1G count=1 oflag=direct


    which gives back something like this:



    1 oflag=direct
    1+0 records in
    1+0 records out
    1073741824 bytes (1,1 GB, 1,0 GiB) copied, 8,52315 s, 126 MB/s


    Now I would like to pipe this output, not the file dd is writing, but to a separate file.



    I tried adding



    >> /tmp/foo


    or



    | sudo tee /tmp/foo


    to the dd command, but that just creates an empty file.







    share|improve this question
























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I use this dd command for checking disk speed:



      dd if=/dev/zero of=/path/file bs=1G count=1 oflag=direct


      which gives back something like this:



      1 oflag=direct
      1+0 records in
      1+0 records out
      1073741824 bytes (1,1 GB, 1,0 GiB) copied, 8,52315 s, 126 MB/s


      Now I would like to pipe this output, not the file dd is writing, but to a separate file.



      I tried adding



      >> /tmp/foo


      or



      | sudo tee /tmp/foo


      to the dd command, but that just creates an empty file.







      share|improve this question














      I use this dd command for checking disk speed:



      dd if=/dev/zero of=/path/file bs=1G count=1 oflag=direct


      which gives back something like this:



      1 oflag=direct
      1+0 records in
      1+0 records out
      1073741824 bytes (1,1 GB, 1,0 GiB) copied, 8,52315 s, 126 MB/s


      Now I would like to pipe this output, not the file dd is writing, but to a separate file.



      I tried adding



      >> /tmp/foo


      or



      | sudo tee /tmp/foo


      to the dd command, but that just creates an empty file.









      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 30 at 15:06









      Kusalananda

      103k13202318




      103k13202318










      asked Jan 30 at 14:37









      rookie_senior

      82




      82




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          3
          down vote



          accepted










          To be able to insert dd in a pipeline before or after another command, its informational messages are written to standard error rather than to standard output.



          The OpenBSD manual for dd explicitly mentions this (but the Ubuntu manual seems to omit this fact, but mentions it in the more complete info page):




          When finished, dd displays the
          number of complete and partial input and output blocks and truncated
          input records to the standard error output.




          To redirect standard error from a command, use 2>filename. To append the standard error stream to an already existing file without truncating it, use 2>>filename.



          For example:



          dd if=/dev/zero of=/path/file bs=1G count=1 oflag=direct 2>dd.txt



          Note that you mix appending output in the first of your examples (using >>) with truncating output in your second example (using tee). To append to a file with tee, use tee -a.






          share|improve this answer






















          • The manual of GNU dd is in the info page, the man page is just a dump of dd --help for convenience for people who are not used to info documentation and/or just want a quick reference with a pager. The bottom of the page will tell you where to look for the actual manual (where the writing to stderr is documented).
            – Stéphane Chazelas
            Jan 30 at 15:43











          • @StéphaneChazelas Thanks, I added a short mentianing of that. I personally have never been a friend of the info system... :-/
            – Kusalananda
            Jan 30 at 15:45










          • Thanks for this clear and concise answer. Just to be clear: Using tee will not work in this case, because it does not read from stderr, correct?
            – rookie_senior
            Jan 30 at 15:47










          • @rookie_senior dd ... 2>&1 | tee ... would work.
            – Kusalananda
            Jan 30 at 15:48

















          up vote
          2
          down vote













          dd output is actually printing to stderr not stdout



          You can redirect stderr to a file for your dd command as follows:



          $ dd if=/dev/zero of=/path/file bs=1G count=1 oflag=direct
          2>> /path/to/file






          share|improve this answer




















            Your Answer







            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "106"
            ;
            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',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );








             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f420692%2fhow-to-write-dd-status-result-message-to-a-file%23new-answer', 'question_page');

            );

            Post as a guest






























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            3
            down vote



            accepted










            To be able to insert dd in a pipeline before or after another command, its informational messages are written to standard error rather than to standard output.



            The OpenBSD manual for dd explicitly mentions this (but the Ubuntu manual seems to omit this fact, but mentions it in the more complete info page):




            When finished, dd displays the
            number of complete and partial input and output blocks and truncated
            input records to the standard error output.




            To redirect standard error from a command, use 2>filename. To append the standard error stream to an already existing file without truncating it, use 2>>filename.



            For example:



            dd if=/dev/zero of=/path/file bs=1G count=1 oflag=direct 2>dd.txt



            Note that you mix appending output in the first of your examples (using >>) with truncating output in your second example (using tee). To append to a file with tee, use tee -a.






            share|improve this answer






















            • The manual of GNU dd is in the info page, the man page is just a dump of dd --help for convenience for people who are not used to info documentation and/or just want a quick reference with a pager. The bottom of the page will tell you where to look for the actual manual (where the writing to stderr is documented).
              – Stéphane Chazelas
              Jan 30 at 15:43











            • @StéphaneChazelas Thanks, I added a short mentianing of that. I personally have never been a friend of the info system... :-/
              – Kusalananda
              Jan 30 at 15:45










            • Thanks for this clear and concise answer. Just to be clear: Using tee will not work in this case, because it does not read from stderr, correct?
              – rookie_senior
              Jan 30 at 15:47










            • @rookie_senior dd ... 2>&1 | tee ... would work.
              – Kusalananda
              Jan 30 at 15:48














            up vote
            3
            down vote



            accepted










            To be able to insert dd in a pipeline before or after another command, its informational messages are written to standard error rather than to standard output.



            The OpenBSD manual for dd explicitly mentions this (but the Ubuntu manual seems to omit this fact, but mentions it in the more complete info page):




            When finished, dd displays the
            number of complete and partial input and output blocks and truncated
            input records to the standard error output.




            To redirect standard error from a command, use 2>filename. To append the standard error stream to an already existing file without truncating it, use 2>>filename.



            For example:



            dd if=/dev/zero of=/path/file bs=1G count=1 oflag=direct 2>dd.txt



            Note that you mix appending output in the first of your examples (using >>) with truncating output in your second example (using tee). To append to a file with tee, use tee -a.






            share|improve this answer






















            • The manual of GNU dd is in the info page, the man page is just a dump of dd --help for convenience for people who are not used to info documentation and/or just want a quick reference with a pager. The bottom of the page will tell you where to look for the actual manual (where the writing to stderr is documented).
              – Stéphane Chazelas
              Jan 30 at 15:43











            • @StéphaneChazelas Thanks, I added a short mentianing of that. I personally have never been a friend of the info system... :-/
              – Kusalananda
              Jan 30 at 15:45










            • Thanks for this clear and concise answer. Just to be clear: Using tee will not work in this case, because it does not read from stderr, correct?
              – rookie_senior
              Jan 30 at 15:47










            • @rookie_senior dd ... 2>&1 | tee ... would work.
              – Kusalananda
              Jan 30 at 15:48












            up vote
            3
            down vote



            accepted







            up vote
            3
            down vote



            accepted






            To be able to insert dd in a pipeline before or after another command, its informational messages are written to standard error rather than to standard output.



            The OpenBSD manual for dd explicitly mentions this (but the Ubuntu manual seems to omit this fact, but mentions it in the more complete info page):




            When finished, dd displays the
            number of complete and partial input and output blocks and truncated
            input records to the standard error output.




            To redirect standard error from a command, use 2>filename. To append the standard error stream to an already existing file without truncating it, use 2>>filename.



            For example:



            dd if=/dev/zero of=/path/file bs=1G count=1 oflag=direct 2>dd.txt



            Note that you mix appending output in the first of your examples (using >>) with truncating output in your second example (using tee). To append to a file with tee, use tee -a.






            share|improve this answer














            To be able to insert dd in a pipeline before or after another command, its informational messages are written to standard error rather than to standard output.



            The OpenBSD manual for dd explicitly mentions this (but the Ubuntu manual seems to omit this fact, but mentions it in the more complete info page):




            When finished, dd displays the
            number of complete and partial input and output blocks and truncated
            input records to the standard error output.




            To redirect standard error from a command, use 2>filename. To append the standard error stream to an already existing file without truncating it, use 2>>filename.



            For example:



            dd if=/dev/zero of=/path/file bs=1G count=1 oflag=direct 2>dd.txt



            Note that you mix appending output in the first of your examples (using >>) with truncating output in your second example (using tee). To append to a file with tee, use tee -a.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Jan 30 at 15:45

























            answered Jan 30 at 14:58









            Kusalananda

            103k13202318




            103k13202318











            • The manual of GNU dd is in the info page, the man page is just a dump of dd --help for convenience for people who are not used to info documentation and/or just want a quick reference with a pager. The bottom of the page will tell you where to look for the actual manual (where the writing to stderr is documented).
              – Stéphane Chazelas
              Jan 30 at 15:43











            • @StéphaneChazelas Thanks, I added a short mentianing of that. I personally have never been a friend of the info system... :-/
              – Kusalananda
              Jan 30 at 15:45










            • Thanks for this clear and concise answer. Just to be clear: Using tee will not work in this case, because it does not read from stderr, correct?
              – rookie_senior
              Jan 30 at 15:47










            • @rookie_senior dd ... 2>&1 | tee ... would work.
              – Kusalananda
              Jan 30 at 15:48
















            • The manual of GNU dd is in the info page, the man page is just a dump of dd --help for convenience for people who are not used to info documentation and/or just want a quick reference with a pager. The bottom of the page will tell you where to look for the actual manual (where the writing to stderr is documented).
              – Stéphane Chazelas
              Jan 30 at 15:43











            • @StéphaneChazelas Thanks, I added a short mentianing of that. I personally have never been a friend of the info system... :-/
              – Kusalananda
              Jan 30 at 15:45










            • Thanks for this clear and concise answer. Just to be clear: Using tee will not work in this case, because it does not read from stderr, correct?
              – rookie_senior
              Jan 30 at 15:47










            • @rookie_senior dd ... 2>&1 | tee ... would work.
              – Kusalananda
              Jan 30 at 15:48















            The manual of GNU dd is in the info page, the man page is just a dump of dd --help for convenience for people who are not used to info documentation and/or just want a quick reference with a pager. The bottom of the page will tell you where to look for the actual manual (where the writing to stderr is documented).
            – Stéphane Chazelas
            Jan 30 at 15:43





            The manual of GNU dd is in the info page, the man page is just a dump of dd --help for convenience for people who are not used to info documentation and/or just want a quick reference with a pager. The bottom of the page will tell you where to look for the actual manual (where the writing to stderr is documented).
            – Stéphane Chazelas
            Jan 30 at 15:43













            @StéphaneChazelas Thanks, I added a short mentianing of that. I personally have never been a friend of the info system... :-/
            – Kusalananda
            Jan 30 at 15:45




            @StéphaneChazelas Thanks, I added a short mentianing of that. I personally have never been a friend of the info system... :-/
            – Kusalananda
            Jan 30 at 15:45












            Thanks for this clear and concise answer. Just to be clear: Using tee will not work in this case, because it does not read from stderr, correct?
            – rookie_senior
            Jan 30 at 15:47




            Thanks for this clear and concise answer. Just to be clear: Using tee will not work in this case, because it does not read from stderr, correct?
            – rookie_senior
            Jan 30 at 15:47












            @rookie_senior dd ... 2>&1 | tee ... would work.
            – Kusalananda
            Jan 30 at 15:48




            @rookie_senior dd ... 2>&1 | tee ... would work.
            – Kusalananda
            Jan 30 at 15:48












            up vote
            2
            down vote













            dd output is actually printing to stderr not stdout



            You can redirect stderr to a file for your dd command as follows:



            $ dd if=/dev/zero of=/path/file bs=1G count=1 oflag=direct
            2>> /path/to/file






            share|improve this answer
























              up vote
              2
              down vote













              dd output is actually printing to stderr not stdout



              You can redirect stderr to a file for your dd command as follows:



              $ dd if=/dev/zero of=/path/file bs=1G count=1 oflag=direct
              2>> /path/to/file






              share|improve this answer






















                up vote
                2
                down vote










                up vote
                2
                down vote









                dd output is actually printing to stderr not stdout



                You can redirect stderr to a file for your dd command as follows:



                $ dd if=/dev/zero of=/path/file bs=1G count=1 oflag=direct
                2>> /path/to/file






                share|improve this answer












                dd output is actually printing to stderr not stdout



                You can redirect stderr to a file for your dd command as follows:



                $ dd if=/dev/zero of=/path/file bs=1G count=1 oflag=direct
                2>> /path/to/file







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 30 at 14:52









                imbuedHope

                1968




                1968






















                     

                    draft saved


                    draft discarded


























                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f420692%2fhow-to-write-dd-status-result-message-to-a-file%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Popular posts from this blog

                    How to check contact read email or not when send email to Individual?

                    Bahrain

                    Postfix configuration issue with fips on centos 7; mailgun relay