How to remove headers when concatenating multiple files

After trying numerous commands and OS for this, I settled upon the most succinct and efficient; The ‘awk’ command (Linux).

awk 'FNR==1 && NR!=1{next;}{print}' *.csv> ALL.csv

FNR is the number of records/lines read of current file
NR is the number of records/lines read overall

The query therefore, works by saying skip the line if it’s the first line of the current file, and at least 1 line has been read overall.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s