Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I sort num ip in order by number? 3

Status
Not open for further replies.

john99999

Instructor
Apr 29, 2005
73
US
How do I get this commend to display the number of occurances if the ips in order?
cat domain.com | awk {'print $1'} | uniq -c
4 69.6.129.15
1 207.91.154.86
1 69.6.129.15
2 207.91.154.86
1 24.81.86.192
9 207.91.154.86
1 67.70.56.142
1 148.235.92.153
13 207.91.154.86
1 80.60.193.189
5 207.91.154.86
1 82.50.96.121
4 207.91.154.86

I want it to display it like:
13 207.91.154.86
9 207.91.154.86
5 207.91.154.86
4 69.6.129.15
4 207.91.154.86
1 207.91.154.86
2 207.91.154.86
1 69.6.129.15
1 24.81.86.192
1 67.70.56.142
1 148.235.92.153
1 80.60.193.189
1 82.50.96.121

What is the correct commend for that?
 
Or...
Code:
cat domain.com | awk {'print $1'} | uniq -c | sort -rn
Hope this helps.
 
.... OR ....

cat domain.com | perl sortthis.pl

Code:
sortthis.pl

#!/usr/bin/perl
my @ips;

while (<>) {
  chomp;
  push(@ips);
}
foreach my $ip (sort {$b <=> $a} @ips) {
 print "$ip\n";
}



D.E.R. Management - IT Project Management Consulting
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top