By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,541 Members | 1,476 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,541 IT Pros & Developers. It's quick & easy.

Compare two files and print difference

P: 1
Hello Experts

I have two files file1 and file2, both have IP addresses.
Basically i want a comparison in which i can get any new IPs present in file2 when compared it with file1 and viceversa.

Example:
File1
172.30.80.1
172.30.80.2
172.30.80.3
172.30.80.21
172.30.80.22
172.30.80.23
172.30.80.25
172.30.80.27
172.30.80.28
172.30.80.29
172.30.80.30
172.30.80.31
172.30.80.32
(up to 650 plus IP's)

File2:

have lot of IPs same as file but some new IP's too which may not present in file1.

So how to compare both files using perl or any other unix script.

I'm a newbie as far as scripting is considered, Please help.

Thanks
Siva Murugan
Aug 14 '10 #1
Share this Question
Share on Google+
1 Reply


Expert
P: 70
Since you are on unix, you can use sort and comm. comm will show you which IPs are present in both files and which are unique to both files.
Aug 14 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.