Automating the comparison of text files


(Helen) #1

I have a set of log files (.txt) that I want to compare to new log files (they should be pretty much the same but there may be some differences that are OK and can be ignored). Currently I am producing the new log files then using the Compare PlugIn on Notepad++ and scrolling through to check the differences. Please can anyone suggest how this might be automated so only the differences I care about are highlighted and reported to me.


(Burdette) #2

In Ruby, I use gem diff-lcs. Check the documentation.

For other languages, try web-search for “diff lcs <your_language>”.


(Kamil) #3

To be honest for such a simple task i would write a simple script in (i.e python) using difflib, it’s well explained there https://pymotw.com/3/difflib/index.html, but as @burdettelamar written it could be also done in Ruby, i think you would find solution to this problem in every possible language, cool feature to implement also would be, that the script would run automatically every time change to file is made and store it in some txt :wink:


(João Farias) #4

Unix itself has a diff command: https://www.networkworld.com/article/2696092/operating-systems/unix---having-fun-with-diff.html

And, naturally, you can chain the output into other Unix commands and do all kind of magic.


30 Days of Automation in Testing Day 3: Explore "The Club" and Contribute