head -n -5 file

Category: Administration

head -n -5 file

Print all but the last five lines

A negative count flips head around, so -n -5 prints every line except the final five. This is the mirror of tail -n -5 and handy when the end of a file contains a footer you want to exclude. The feature needs the explicit -n form.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.