Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Search Forums:



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 !!

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

Join Date: Jul 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
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
Sponsored Links
    #2  
Old 07-04-2003
Registered User
 

Join Date: Jul 2002
Location: Belgium
Posts: 30
Thanks: 1
Thanked 0 Times in 0 Posts
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

Sponsored Links
    #3  
Old 07-04-2003
Registered User
 

Join Date: Jul 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
It works

THanks so much man!
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 06:00 AM
Duplicate lines in the file guptan UNIX for Advanced & Expert Users 3 05-18-2006 05:28 AM
Counting Number of times a File is accessed pathanjalireddy Shell Programming and Scripting 1 04-11-2005 09:49 AM
counting the number of lines nayeemmz Linux 6 01-19-2005 11:37 AM
Counting the number of lines in ASCII file alarmcall Shell Programming and Scripting 8 08-26-2003 06:53 PM



All times are GMT -4. The time now is 03:14 AM.