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


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 ?


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


  • -n do not print input
  • 2,$ select line from 2 to end of file
  • p print
  • 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

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.