awk processing

Hi all
Is there a way in awk to know that you are processing your final line of input if you do no know how many lines were in the input to begin with?

Thanks

You can do something like:

awk -v nlines=$(wc -l < file) 'NR==nlines{We are on the last line...}' file

Regards

awk 'NR==FNR { next }' file

thanks ppl

kmuqalled,

This shouldn't work, did you try it?

Regards

use the end block of the awk

that is executed after the last line

It depends on what adaptions you're doing with a file, if you just want to adapt the awk variables of the last record you can use the END block as matrixmadhan mentioned!:wink:

Regards