How to output all lines of a file without the last line? How to output all lines of a file without the last line? shell shell

How to output all lines of a file without the last line?


BASH, using head:

$ head --lines=-1 filename

Same for Mac:

expr "$a" : '\(.*\)'

The newline is required!


Probably the shortest way:

sed '$d' filename