Skip to content
Advertisement

Compare two text files line by line, finding differences but ignoring numerical values differences

I’m working on a bash script to compare two similar text files line by line and find the eventual differences between each line of the files, I should point the difference and tell in which line the difference is, but I should ignore the numerical values in this comparison.

Example:

JavaScript

In the example above, the script shouldn’t find any difference since it’s just the process id and it changes all the time.

But otherwise I want it to notify me of the differences between the lines.

Example:

JavaScript

I already have a working script to find the differences, and i’ve used the following function to find the difference and ignore the numerical values, but it’s not working perfectly, Any suggestions ?

JavaScript

Where $1 and $2 are the two files to compare.

Advertisement

Answer

Would you please try the following:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement