find out the record number to which the max length belongs.
Hi All,
I have a huge file, in which I have used below command to get the maximum record length in the file. $ awk ' { if ( length > L ) { L=length} }END{ print L}' abc.csv Output: 27151 Now, I would like to find out the record number to which this max length belongs. For Example: Record# 850 has maximum length "27151" Request you all to please have a look at this query. Thanks, Vaibhav |
You could use the NR variable:
Code:
awk ' { if ( length > L ) { L=length ; LINE=NR } }END{ print "Record " LINE " has maximum length " L}' abc.csv |
Thank you so much.
It worked for me |
All times are GMT -5. The time now is 10:35 PM. |