Solved

Linux, difference between configuration files

Posted on 2014-11-20
3
177 Views
Last Modified: 2014-11-20
On Red Hat 6.x, I need a tool that will tell me the difference between 2 configuration files

Is there a tool that will do that

Also , is there a tool that will approach this in a more complex manner, and will NOT report all lines after the first mismatch, but will only report lines in the first file that are not contained in the second file ?  For Instance:

a.conf

Line 1
Line 2
Line 3
line 4
line 5
line  6

Open in new window


and b.conf

Line 1
Line 2
line 4
line 5
line  6

Open in new window


is there a tool that will report the difference as :

Line 3

Open in new window


instead of

Line 3
line 4
line 5
line  6

Open in new window


Thanks
0
Comment
Question by:Anthony Lucia
  • 2
3 Comments
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 40455407
The first tool yu're looking for is "diff".

The second tool you're looking for is "comm":

comm -2 -3 a.conf b.conf

comm creates 3 reports (in 3 columns):
1. Lines only in file 1
2 Lines only in file 2
3. Lines common to file 1 and file 2

The options "-1" "-2" and "-3" suppress displaying the respective column.
0
 
LVL 21

Expert Comment

by:Mazdajai
ID: 40455409
Try diff

diff a.conf b.conf

Open in new window

0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
ID: 40455446
Note: Please be aware that the files to compare must be sorted to create reliable results!
Your files are sorted, that's why it works in your case.

With non-sorted files, if you don't want to touch the originals, you can create sorted temporary versions and compare these.

"comm" accepts standard input for one of the input files, so only one of them must be sorted into a file.

sort b.conf > b.conf.sorted
sort a.conf | comm -2 -3 - b.conf.sorted

Note the dash (-) as the first file parameter. It means: "read from stdin".
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Issue to mail 11 69
cannot connect to openvpn server 9 59
nagios alerts 3 32
How can you tell your public IP address without a browser? 9 52
How many times have you wanted to quickly do the same thing to a list but found yourself typing it again and again? I first figured out a small time saver with the up arrow to recall the last command but that can only get you so far if you have a bi…
Linux users are sometimes dumbfounded by the severe lack of documentation on a topic. Sometimes, the documentation is copious, but other times, you end up with some obscure "it varies depending on your distribution" over and over when searching for …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now