How to redirect output of more to a file

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











up vote
0
down vote

favorite












I would like to pipe the output of tree command to more, ignoring the first line. Then redirect the output of more command to a file. If I type



tree SOME_DIRECTORY | more +2 >> OUTPUT_FILE


The first line still appears in OUTPUT_FILE.



But if I type



tree SOME_DIRECTORY | more +2


the first line doesn't appear on the terminal.



Can anyone point out what mistake I was making ?







share|improve this question


























    up vote
    0
    down vote

    favorite












    I would like to pipe the output of tree command to more, ignoring the first line. Then redirect the output of more command to a file. If I type



    tree SOME_DIRECTORY | more +2 >> OUTPUT_FILE


    The first line still appears in OUTPUT_FILE.



    But if I type



    tree SOME_DIRECTORY | more +2


    the first line doesn't appear on the terminal.



    Can anyone point out what mistake I was making ?







    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I would like to pipe the output of tree command to more, ignoring the first line. Then redirect the output of more command to a file. If I type



      tree SOME_DIRECTORY | more +2 >> OUTPUT_FILE


      The first line still appears in OUTPUT_FILE.



      But if I type



      tree SOME_DIRECTORY | more +2


      the first line doesn't appear on the terminal.



      Can anyone point out what mistake I was making ?







      share|improve this question














      I would like to pipe the output of tree command to more, ignoring the first line. Then redirect the output of more command to a file. If I type



      tree SOME_DIRECTORY | more +2 >> OUTPUT_FILE


      The first line still appears in OUTPUT_FILE.



      But if I type



      tree SOME_DIRECTORY | more +2


      the first line doesn't appear on the terminal.



      Can anyone point out what mistake I was making ?









      share|improve this question













      share|improve this question




      share|improve this question








      edited Oct 29 '17 at 9:11









      Archemar

      19k93366




      19k93366










      asked Oct 29 '17 at 9:05









      Pin-Yen

      32




      32




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          2
          down vote



          accepted










          more (or less) are rather to be used interactively.



          use either tail



          tree SOME_DIRECTORY | tail +2 >> output_file


          this tell tail to list line, starting from 2nd (line N°2)



          or awk



          tree SOME_DIRECTORY | awk 'NR>1' >> output_file


          this tell awk to print (default action) line whose number (NR: Number Record) is above 1 (you can also use NR>=2 )



          or sed (thank to Kusalananda )



          tree SOME_DIRECTORY | sed -n '2,$p' >> output_file


          where




          • -n do not print input


          • 2,$ select line from 2 to end of file


          • p print





          share|improve this answer






















          • Or sed -n '2,$p'
            – Kusalananda
            Oct 29 '17 at 9:13










          • Or ( read && cat ) <file >newfile ;-)
            – Kusalananda
            Oct 29 '17 at 9:15










          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%2f401178%2fhow-to-redirect-output-of-more-to-a-file%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          2
          down vote



          accepted










          more (or less) are rather to be used interactively.



          use either tail



          tree SOME_DIRECTORY | tail +2 >> output_file


          this tell tail to list line, starting from 2nd (line N°2)



          or awk



          tree SOME_DIRECTORY | awk 'NR>1' >> output_file


          this tell awk to print (default action) line whose number (NR: Number Record) is above 1 (you can also use NR>=2 )



          or sed (thank to Kusalananda )



          tree SOME_DIRECTORY | sed -n '2,$p' >> output_file


          where




          • -n do not print input


          • 2,$ select line from 2 to end of file


          • p print





          share|improve this answer






















          • Or sed -n '2,$p'
            – Kusalananda
            Oct 29 '17 at 9:13










          • Or ( read && cat ) <file >newfile ;-)
            – Kusalananda
            Oct 29 '17 at 9:15














          up vote
          2
          down vote



          accepted










          more (or less) are rather to be used interactively.



          use either tail



          tree SOME_DIRECTORY | tail +2 >> output_file


          this tell tail to list line, starting from 2nd (line N°2)



          or awk



          tree SOME_DIRECTORY | awk 'NR>1' >> output_file


          this tell awk to print (default action) line whose number (NR: Number Record) is above 1 (you can also use NR>=2 )



          or sed (thank to Kusalananda )



          tree SOME_DIRECTORY | sed -n '2,$p' >> output_file


          where




          • -n do not print input


          • 2,$ select line from 2 to end of file


          • p print





          share|improve this answer






















          • Or sed -n '2,$p'
            – Kusalananda
            Oct 29 '17 at 9:13










          • Or ( read && cat ) <file >newfile ;-)
            – Kusalananda
            Oct 29 '17 at 9:15












          up vote
          2
          down vote



          accepted







          up vote
          2
          down vote



          accepted






          more (or less) are rather to be used interactively.



          use either tail



          tree SOME_DIRECTORY | tail +2 >> output_file


          this tell tail to list line, starting from 2nd (line N°2)



          or awk



          tree SOME_DIRECTORY | awk 'NR>1' >> output_file


          this tell awk to print (default action) line whose number (NR: Number Record) is above 1 (you can also use NR>=2 )



          or sed (thank to Kusalananda )



          tree SOME_DIRECTORY | sed -n '2,$p' >> output_file


          where




          • -n do not print input


          • 2,$ select line from 2 to end of file


          • p print





          share|improve this answer














          more (or less) are rather to be used interactively.



          use either tail



          tree SOME_DIRECTORY | tail +2 >> output_file


          this tell tail to list line, starting from 2nd (line N°2)



          or awk



          tree SOME_DIRECTORY | awk 'NR>1' >> output_file


          this tell awk to print (default action) line whose number (NR: Number Record) is above 1 (you can also use NR>=2 )



          or sed (thank to Kusalananda )



          tree SOME_DIRECTORY | sed -n '2,$p' >> output_file


          where




          • -n do not print input


          • 2,$ select line from 2 to end of file


          • p print






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Oct 29 '17 at 9:17

























          answered Oct 29 '17 at 9:12









          Archemar

          19k93366




          19k93366











          • Or sed -n '2,$p'
            – Kusalananda
            Oct 29 '17 at 9:13










          • Or ( read && cat ) <file >newfile ;-)
            – Kusalananda
            Oct 29 '17 at 9:15
















          • Or sed -n '2,$p'
            – Kusalananda
            Oct 29 '17 at 9:13










          • Or ( read && cat ) <file >newfile ;-)
            – Kusalananda
            Oct 29 '17 at 9:15















          Or sed -n '2,$p'
          – Kusalananda
          Oct 29 '17 at 9:13




          Or sed -n '2,$p'
          – Kusalananda
          Oct 29 '17 at 9:13












          Or ( read && cat ) <file >newfile ;-)
          – Kusalananda
          Oct 29 '17 at 9:15




          Or ( read && cat ) <file >newfile ;-)
          – Kusalananda
          Oct 29 '17 at 9:15

















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f401178%2fhow-to-redirect-output-of-more-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?

          Displaying single band from multi-band raster using QGIS

          How many registers does an x86_64 CPU actually have?