How can I discard the last n lines of a file with a unix command line filter?
That would be sort of the opposite of tail
: tail
discards the first n lines but pipes the rest through, but I want the command to pipe everything through except the last n lines.
Unfortunately I haven't found anything like that - head
doesnt help, too. EDIT: At least in Solaris it does not take negative arguments.
Update: I'm mostly interested in a solution that works for big files, i.e. logfiles, where you might want to inspect what happened except in the last minutes.
tail
is what you want.