Sort and remove uniques
Page 1 of 1

Author:  xaban [ Thu May 20, 2010 11:53 am ]
Post subject:  Sort and remove uniques

I am not sure if this is possible with bash, if it is not, I have to find another way to sort it out.

I have a file, for example IPs.txt. In the file I have several IP addresses listed.
If the IP is listed in the file for 5 or more times, I want to hold in, otherwise I want to delete the IP address. So every IP which is not listed >5 must be deleted.

So at the end I will end with a file with only with the IP's which were listed 5 or more times.

Author:  choroba [ Thu May 20, 2010 3:07 pm ]
Post subject:  Re: Sort and remove uniques

The first thing to do is to run this:
sort | uniq -c | sort -n

The rest is easy B-)

Author:  xaban [ Sun May 23, 2010 1:43 am ]
Post subject:  Re: Sort and remove uniques

I found a really easy way, for example to list only the IP's which are duplicate for more than 5 times:
awk 'seen[$0]++ == 5' IPs.txt

Page 1 of 1 All times are UTC - 6 hours
© 2000, 2002, 2005, 2007 phpBB Group •