Bash tricks: drop the first line of a file

I work with a bunch of data that often comes in text files. I regularly want to cut off the header / first line, but I thought that to use tail you had to know how many lines are in your file. It turns out that if you just use

$ tail -n +2 [file]

it will just skip the first line without forcing you to know how many lines there are.

earl $ cat a.csv
1
2
3
4
earl $ tail -n +2 a.csv
2
3
4

This is much more convenient for piping into awk or other commands downstream.

This entry was posted in bash, Data Munging. Bookmark the permalink.

One Response to Bash tricks: drop the first line of a file

  1. a3_nm says:

    Shorter:

    $ sed 1d a.csv

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>