linuxunixtailunix-head

select the second line to last line of a file


How can I select the lines from the second line to the line before the last line of a file by using head and tail in unix?

For example if my file has 15 lines I want to select lines from 2 to 14.


Solution

  • tail -n +2 /path/to/file | head -n -1