How can I cat/print a file except the last 2 lines?

Solution 1:

Use the head command from coreutils:

head -n -2

See info head for more.

Solution 2:

You simply want.

head -n-2 file

Read man head for more information.