-
Today, I needed to script removing the last couple lines of a file from the shell. The
headcommand shipped by macOS doesn't support-n -2But theirtailcommand totally supports-n +3tac myfile.txt | tail -n +3 |tac -
Ugh. I don't actually have 'tac' by default on macOS.
-
Sigh. time for the trivial perl script.
-
On second thought. cat file.txt | sed '$d'| sed '$d' is inelegant but unambiguous.