LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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, 02:14 AM   #1
vaibhavs17
Member
 
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.

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

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, 02:34 AM   #3
vaibhavs17
Member
 
Registered: Mar 2009
Posts: 51

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

It worked for me
 
  


Reply



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:45 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
Open Source Consulting | Domain Registration