-   Programming (
-   -   bash script - remove header row from csv file (

pljvaldez 08-14-2006 12:55 PM

bash script - remove header row from csv file
I'm trying to write a script to automatically take our company phone directory every month and convert it to a palm database file so I have a complete updated directory with me.

Anyway, the script works great, but there's a row of garbage at the top of the file that I'm stumped by.

I've been googling around trying to figure out how to get rid of it and haven't found what I'm looking for. I'm sure there must be a simple awk or bash command that can just whack off the top row of a file, but I'm struggling to find it.

I can live with it, but I was thinking of releasing the phone directory to the rest of the company and would like it to be pretty flawless before I do so.

pljvaldez 08-14-2006 01:25 PM

Never mind.

sed '1d' file.txt > file.csv

burninGpi 08-14-2006 01:26 PM

You want to remove the first line of the file? Here's an awk script:

awk 'FNR>1{print}' file.txt

Andrew Benton 08-14-2006 01:27 PM

sed -i '1d' /path/to/filename.txt

osor 08-14-2006 01:39 PM

Alternately, sed '2,$p' /path/to/file

Tim Retout 08-30-2006 12:05 PM

Yet another alternative:


tail -n+2 /path/to/file > /path/to/output
Test with something like:


echo -e "foo\nbar\nbaz" | tail -n+2

All times are GMT -5. The time now is 04:05 PM.