How to remove all india IPs from a text file ?

General support questions
Post Reply
Deeresh
Posts: 17
Joined: 2014/03/06 05:21:28

How to remove all india IPs from a text file ?

Post by Deeresh » 2015/03/09 05:48:53

Hi,

I have two files. The first one contains the list of all INDIA IPs (Subnets ) and the second one has list of IPs all countries.

I just want to remove all the INDIA IPs from the second file.

Please help me. Thanks in advance.

giulix63
Posts: 1305
Joined: 2014/05/14 10:06:37
Location: UK

Re: How to remove all india IPs from a text file ?

Post by giulix63 » 2015/03/09 10:20:56

First sort them

Code: Select all

sort -u -t. -k1,1n -k2,2n -k3,3n -k4,4n <in.zone >in.zone.sorted
sort -u -t. -k1,1n -k2,2n -k3,3n -k4,4n <all.zone >all.zone.sorted
then filter out equal entries

Code: Select all

sdiff -ls in.zone.sorted all.zone.sorted
P.S. This actually works only for IPv4 addresses, but the concept is applicable to any IP type
Root is evil: Do not use root (sudo) to run any of the commands specified in my posts unless explicitly indicated. Please, provide the necessary amount of context to understand your problem/question.

Post Reply