obra’s avatarobra’s Twitter Archive—№ 45,769

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