Find the answer to your Linux question:
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
Hi Friends, i often compare two different files which differ slightly in there contents can you suggest me any tool or utility which will make my task easier. At present ...
  1. #1
    Just Joined!
    Join Date
    Apr 2010
    Posts
    12

    Comapre two different files easily

    Hi Friends, i often compare two different files which differ slightly in there contents can you suggest me any tool or utility which will make my task easier.

    At present i am using diff, sdiff command to compare the files any better option than this ?

  2. #2
    Linux Guru Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    2,097
    What´s wrong with diff? Perfect for the job

    But if you look for a graphical tool, try Meld : Screenshots
    You must always face the curtain with a bow.

  3. #3
    Just Joined!
    Join Date
    Apr 2010
    Posts
    12
    diff command's output is difficult to grasp quickly so want some other option to compare files

  4. #4
    Just Joined!
    Join Date
    Mar 2006
    Location
    Manila, Philippines
    Posts
    3

    Smile RE: Comapre two different files easily

    Aside from diff and sdiff you can use cmp command which compares two files and tells you which line numbers are different. Others use perl script to compare the 2 files which allows them to manipulate the output of comparisson between the two files.

  5. #5
    Just Joined!
    Join Date
    Apr 2010
    Posts
    12
    Quote Originally Posted by reddragon865 View Post
    Aside from diff and sdiff you can use cmp command which compares two files and tells you which line numbers are different. Others use perl script to compare the 2 files which allows them to manipulate the output of comparisson between the two files.
    Hi reddragon can u give me d perl script which gives the diff between files ?

  6. #6
    Linux Guru Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    2,097
    I would still recommend diff.
    It is the standard tool for exactly that task and definitely worth learning.
    You must always face the curtain with a bow.

  7. #7
    Just Joined!
    Join Date
    Apr 2010
    Posts
    12
    Quote Originally Posted by Irithori View Post
    I would still recommend diff.
    It is the standard tool for exactly that task and definitely worth learning.
    Ok friend then i will learn diff.
    One of my friend gave me dis software called Beyond Compare its 2 good 2 compare files

  8. #8
    Just Joined!
    Join Date
    Jun 2010
    Location
    silicon valley
    Posts
    6
    Hi,

    When I want to use diff for files that have only minor differences, and also read the output easily, I do the following command:

    diff -y file1 file2 > output.txt

    This compares the two files side by side and puts the output into a file called output.txt (put whatever name you want there). You don't have to write to an output file but it makes it easier to read, especially for long files. For example I did the following command:

    diff -y e820.c e820.orig.c > e820diff.txt

    Within my e820diff.txt file, lines that are similar but different look like this:

    &e820.map[i+offset], | &e820.map[i+1]

    (the vertical bar shows the lines are similar but contain a change)

    Lines that are in one file but not the other will have a < or > to indicate the line is only in the first or second file, respectively; for example this line:

    i++; <

    was only in the first file I listed.

    Hope that helps! Once you get the hang of using diff, you'll never go back (:

  9. #9
    Just Joined!
    Join Date
    Apr 2010
    Posts
    12
    Quote Originally Posted by sarina View Post
    Hi,

    When I want to use diff for files that have only minor differences, and also read the output easily, I do the following command:

    diff -y file1 file2 > output.txt

    This compares the two files side by side and puts the output into a file called output.txt (put whatever name you want there). You don't have to write to an output file but it makes it easier to read, especially for long files. For example I did the following command:

    diff -y e820.c e820.orig.c > e820diff.txt

    Within my e820diff.txt file, lines that are similar but different look like this:

    &e820.map[i+offset], | &e820.map[i+1]

    (the vertical bar shows the lines are similar but contain a change)

    Lines that are in one file but not the other will have a < or > to indicate the line is only in the first or second file, respectively; for example this line:

    i++; <

    was only in the first file I listed.

    Hope that helps! Once you get the hang of using diff, you'll never go back (:

    Thanks Sarina your post was really informative to me now i will stick to diff command instead of thinking of any software which will not be available for me wherever i use Linux flavours on diff systems

  10. #10
    Just Joined!
    Join Date
    Jun 2010
    Location
    silicon valley
    Posts
    6
    Awesome!!!

    When you have some spare time, make a set of test files that have minor to huge differences; play around with the diff options (read the manual page - man diff) and see what sorts of things you can get it to do. I like seeing the whole file side-by-side; other people prefer to see just the changes, or other options. It's a very powerful tool!

Page 1 of 2 1 2 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...