Compare files in Linux

Not long ago I was working with some .po files and needed a nice and simple diff program to merge 2 files. First I tried the multi-purposed text editor vim.

Using vim as a diff and merge tool:

with Andrej’s article I found some nice tips & tricks and the Vim manual for diff tasks. Some useful commands,

  • vim -o one.txt two.txt three.txt” (for horizontal split), “vim -O one.txt two.txt three.txt ” (for vertical split)
  • go to the next diff point   ” ]c “; go to previous diff point “ [c
  • merge to original “do“, merge from original “dp“.

The window you’ll be looking at will look something like this:

vimdiff

Where text highlighted red will display text which doesn’t match from the files being compared.

Another tool I found was Meld. This program was incredibly simple to use and visually simple to work with.

Using Meld Diff Viewer:

  • open the files (or directories) which you’d like to compare;
  • you will visually see where on the original file the text is at on the other file(s) being compared. Specially useful if the text in the files you’re comparing are in completely separate lines;
  • clicking on arrows between the files being compared, the text will go to or from the original file.

meld_file1

Conclusion:

if you’re working on the command line, vim will do the job quite nicely but can be troublesome to inform you if text in both files are the same but spaced out in different line numbers. On the other hand, Meld was the tool I used for the task since there was basically no learning curve to get started and it displayed very well differences and matches in the file even if text were separated by dozens of line between both files I was comparing.

24 thoughts on “Compare files in Linux

  1. The file comparisson in Linux is very easy to perform in this way. I believe is a good opportunity to have the access at the files in Linux.

  2. I believe everything published was actually very reasonable.
    However, what about this? what if you were to write a killer title?

    I mean, I don’t want to tell you how to run your blog, however what if you added something that grabbed folk’s attention?
    I mean Compare files in Linux | OpenComputer.net is kinda boring.
    You should glance at Yahoo’s home page and see how they create news headlines to get people to click. You might try adding a video or a related picture or two to get people interested about what you’ve written.
    In my opinion, it might make your posts a little livelier.

  3. Hey there I am so glad I found your blog page, I really found you by mistake, while I
    was browsing on Google for something else, Regardless I am here now and would just like to say thank you for
    a fantastic post and a all round thrilling blog (I also love the theme/design), I don’t have
    time to go through it all at the moment but I have book-marked it and also added your RSS feeds, so when I have time
    I will be back to read more, Please do keep up the fantastic work.

  4. Hey there would you mind sharing which blog platform you’re working with? I’m going to start my own blog in the near future but I’m having a difficult time deciding between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your layout seems different then most blogs and I’m looking for
    something completely unique. P.S Apologies for getting off-topic but I had
    to ask!

  5. Do you mind if I quote a few of your posts as long as I provide credit and sources
    back to your site? My website is in the very same area of interest as yours and my users would
    truly benefit from a lot of the information you present here.
    Please let me know if this alright with you. Appreciate it!

  6. Hey very cool web site!! Guy .. Excellent .. Wonderful .
    . I will bookmark your blog and take the feeds additionally?

    I’m satisfied to search out a lot of useful information right here within the put up, we’d like develop extra strategies on this
    regard, thanks for sharing. . . . . .

  7. Hi! I’ve been following your site for a while now and finally got the bravery to go ahead and give you a shout out from Dallas Tx! Just wanted to mention keep up the great job!

  8. I just like the valuable information you provide on your articles.
    I will bookmark your weblog and take a look at once more right here frequently.
    I’m somewhat sure I’ll be told many new stuff right right here!
    Best of luck for the next!

  9. Does your site have a contact page? I’m having a tough time locating it but, I’d like to send you an e-mail.
    I’ve got some recommendations for your blog you might be interested in hearing. Either way, great site and I look forward to seeing it expand over time.

  10. The researchers concluded that tooth brushing is a good health habit that could play a role in preventing obesity. Feel the pain, let it evolve to gratitude and eventually, with a breath of kindness, you can blow them away with the wind. Luckily, we live in an era of many technological advances such as smartphones, and tablets that have a myriad of useful apps; so why not use this technology to help you lose weight.

  11. Do a little research, take roofing 47905 pictures of the roof
    face or gable. There are two installation methods, the hot asphalt method is a bit conventional, the cold
    asphalt method. This is in contrast to those that are
    made with recycled content of those same materials.
    To roofing 47905 be able to enjoy your new home
    covering over the last one without the costly and time consuming task of taking off the old home covering.

Leave a Reply

Your email address will not be published. Required fields are marked *