Solved

Linux, difference between configuration files

Posted on 2014-11-20
3
181 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
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 …
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses

623 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