awk, ignore first x number of lines.

Is there a way to tell awk to ignore the first 11 lines of a file?? example, I have a csv file with all the heading information in the first lines. I want to split the file into 5-6 different files but I want to retain the the first 11 lines of the file.

As it is now I run this command:

cat something.csv | nawk '$2 = /servername/' >> something-new.csv

It cuts off the first 11 lines... Right now im just doing two steps to create the file running sed 11q > something-new.csv then running the above command appending something-new.csv. Is there a way to do that with just nawk so I can eliminate the sed command?

Maybe like this:

cat -n something| awk '$1>11 && (the conditions you like)

cat -n adds to the first coloumn the number of line.

Regards

sounds like that will work, then I can just exclude the first column on the print out with awk.

Thanks for the help!

OR:

awk 'NR>11' file

or u can try

awk '{ NR <= 11 {next}
{ ur statments }' <filename>

Yeah Klashxx....this looks more elegant.

hmm, Ive tried these examples. the first 11 are not printed in any of the above statements. Maybe I asked incorrectly? I am looking to have lines 1-11 printed regardless of any parameters I pass with awk.

Perhaps my two command way is the best way to do this?

Try

awk -F',' 'NR <= 11 || $2 = /servername/' filename

Do you want to split your file to different files including the heading (11 first lines) in every file?

awk 'NR <= 11 {print;next}{ do your stuff here with the other lines.. }' file

Provide more information what you're trying to achieve e.g. show your input file and the desired output.

Regards