Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 07-12-2013, 02:14 AM   #1
Registered: Mar 2009
Posts: 51

Rep: Reputation: 1
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.

Old 07-12-2013, 02:22 AM   #2
Ser Olmy
Senior Member
Registered: Jan 2012
Distribution: Slackware
Posts: 2,544

Rep: Reputation: Disabled
You could use the NR variable:
awk ' { if ( length > L ) { L=length ; LINE=NR } }END{ print "Record " LINE " has maximum length " L}' abc.csv
2 members found this post helpful.
Old 07-12-2013, 02:34 AM   #3
Registered: Mar 2009
Posts: 51

Original Poster
Rep: Reputation: 1
Thank you so much.

It worked for me


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Convert length-indicated variable length record file to LF-terminated Z038 Linux - General 10 11-29-2012 11:59 PM
regex problem to find min,max length words in file gvanto Linux - Newbie 4 01-30-2011 05:34 PM
Find the max number Taz_3 Programming 5 12-28-2007 07:43 PM
Cat5 Max Length Jane Linux - Networking 7 06-07-2007 10:26 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:21 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration