Chop "n" lines from the beginning/end of a file

26 Feb 2009

You need some sort of “inverse” for the standard behavior of the head and tail commands, i.e., print everything but the first/last n lines of a file.

To skip the first n = 10 lines of a file

$ awk '(NR > 10)' file

To print everything but the last n = 10 lines of a file

$ head -n -10 file