The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
awk - Counting number of similar lines dhanamurthy Shell Programming and Scripting 8 05-16-2008 03:00 AM
Duplicate lines in the file guptan UNIX for Advanced & Expert Users 3 05-18-2006 02:28 AM
Counting Number of times a File is accessed pathanjalireddy Shell Programming and Scripting 1 04-11-2005 06:49 AM
counting the number of lines nayeemmz Linux 6 01-19-2005 09:37 AM
Counting the number of lines in ASCII file alarmcall Shell Programming and Scripting 8 08-26-2003 03:53 PM

Closed Thread
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 07-04-2003
Registered User
 

Join Date: Jul 2003
Posts: 2
Counting The Number Of Duplicate Lines In a File

Hello. First time poster here. I have a huge file of IP numbers. I am trying to output only the class b of the IPs and rank them by most common and output the total # of duplicate class b's before the class b. An example is below:
12.107.1.1
12.107.9.54
12.108.3.89
12.109.109.4
12.109.6.3


Output would be:
2 12.107
2 12.109

Thanks for the help
Crunchtime
Forum Sponsor
  #2  
Old 07-04-2003
Registered User
 

Join Date: Jul 2002
Location: Belgium
Posts: 20
Wink

As you can see, a simple script does the trick

[dummy806]@@ecar0o:/opt/oracle/TOOLS/generic_unix/scripts> cat ttt
12.107.1.1
12.107.9.54
12.108.3.89
12.109.109.4
12.109.6.3
[dummy806]@@ecar0o:/opt/oracle/TOOLS/generic_unix/scripts> for i in `cat ttt | cut -d"." -f1,2 | uniq`
more>do
more> num=`cat ttt | grep $i | wc -l`
more> if (( $num > 1 ))
more> then
more> echo $num $i
more> fi
more>done
2 12.107
2 12.109

  #3  
Old 07-04-2003
Registered User
 

Join Date: Jul 2003
Posts: 2
It works

THanks so much man!
Google The UNIX and Linux Forums
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 01:15 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0