0

I have a file called "knownIP". This file contain known IP addresses for a group of windows servers. These IP addresses are unique to this group of windows servers.

I have another file called "scanip". This file contain IP addresses from a vulnerability scanner. These IP addresses are: the IP addresses for the group of windows servers plus other operating systems and network devices mixed in.

I would like to do two things:

  1. Compare the file "knownIP" with the file "scanip" and print out the ip's that are not exist in the file "knownIP".
  2. Compare the file "knownIP" with the file "scanip" and print out the ip's that are only exist in the file "knownIP".

Here is my syntax:

if diff knownIP scanip > Output;then
  echo The two files are the same
else
  echo The two files are different
fi

And here is an example of the knownIP file, which is just a file with a list of IP addresses.

172.17.29.14
172.17.28.89
roaima
  • 107,089
  • 14
  • 139
  • 261
ITguru1
  • 13
  • 2
  • 1
    Hi @ITguru1. It would be very nice if you would provide an example sample of the files "knownIP" and "scanip". In addition, to the expected output. –  Sep 17 '18 at 18:46
  • Hi @Goro. The knownIP file is just a file with a list of IP addresses. $ cat knownIP 172.17.29.14 172.17.28.89 – ITguru1 Sep 17 '18 at 19:07

1 Answers1

-3
If diff knownip scanip -eq 0
Then
       Echo "two files are same"
Else
       Echo "two files are different"
       comm knownip scanip > file1
       Cat Not_exist_knownip=scanip-file1 #1
       Cat knownip. #2