select the second line to last line of a file

femchi picture femchi · Oct 3, 2012 · Viewed 15k times · Source

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.

Answer

itsbruce picture itsbruce · Oct 3, 2012
tail -n +2 /path/to/file | head -n -1