Archive for category sed
Remove first and last lines from file in OS X
Posted by Proctor in Command Line, OSX, sed, tail on October 3, 2012
Just a quick post to help burn this into longer term memory.
Today I was having to check some info in a generated csv file that had a header and footer row. I only wanted the records in between, so I needed to remove the first and last lines of that CSV, after I got the columns I needed.
cut <args> my.csv | tail -n +2 | sed '$d'
The tail -n +2
command starts at the second line and outputs the input stream/file. The sed '$d'
command deletes the last line of the file.