I am being sponsored by Syntress! They bought me an amazing dedicated server to run catonmat on. If you're looking web services, I highly recommend the Syntress guys!
Education Sponsors
I am being sponsored by A-Writer! If you ever need help with essay writing, look no further than A-Writer! They will help you with your writing in as quickly as 3 hours!
Serious error in #45, #46 and many others.
FNR is the line number in the *current* file.
NR is the cumulative line number across all inputs.
awk 'code' six_lines.txt ten_lines.txt will have
NR == 1 and FNR == 1
NR == 7 and FNR == 1 again
and END will see NR == 16 and FNR == 10.
Programs that check for change in FILENAME would be more efficient to check for FNR == 1.
Awk to print first 10 lines of several files:
awk 'FNR == 1 { print "\n.... " FILENAME; } FNR < 11
If your awk has "nextfile" it saves reading lines after first 10.
Reply To This Comment