LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 07-12-2013, 03:14 AM   #1
vaibhavs17
Member
 
Registered: Mar 2009
Posts: 49

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.

Thanks,
Vaibhav
 
Old 07-12-2013, 03:22 AM   #2
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 2,404

Rep: Reputation: Disabled
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
 
2 members found this post helpful.
Old 07-12-2013, 03:34 AM   #3
vaibhavs17
Member
 
Registered: Mar 2009
Posts: 49

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

It worked for me
 
  


Reply


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-30-2012 12:59 AM
regex problem to find min,max length words in file gvanto Linux - Newbie 4 01-30-2011 06:34 PM
Find the max number Taz_3 Programming 5 12-28-2007 08:43 PM
Cat5 Max Length Jane Linux - Networking 7 06-07-2007 11:26 AM


All times are GMT -5. The time now is 02:53 PM.

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