This awk command will do ‘stuff 1’ for each line, ‘stuff 2’ only for the first line and ‘stuff 3’ for lines except the first line.
awk '{ { Do stuff 1 } if(NR==1) { Do stuff 2 } else { Do stuff 3 } }'
Based on the above, the below will do ‘stuff 1’ for each line, ‘stuff 2’ when the line is not the first line and ‘stuff 3’ for every line (including the first) correct ??
awk '{ Do stuff 1 } NR!=1 { Do stuff 2 } { Do stuff 3 }'
Or will ‘stuff 2’ and ‘stuff 3’ be executed for only lines where NR!=1 ??
On a 5 lines input:
So, the stuff3 is allways done(exactly like stuff1). Only stuff2 is affected by condition.