Ignoring differences in differences

When doing recursive differences, I want to ignore the expected differences / translations - is there a way to do this with standard unix tools?

eg.

file1: 1 ... 2 /path/to/something/ver1/blah/blah 3 /path/to/something/ver1/blah/blah 4 ... file2: 1 ... 2 /path/to/something/ver2/blah/blah 3 /path/to/something/ver3/blah/blah 4 ... 

I want to be able to do something like:

 diff file1 file2 --ignore-transltion "ver1>ver2" 

It should only show me that line 3 is different

Does anyone know how to do this? I can easily write a perl script to do this, but I will return to implementing most of the rest of the diff functions.

Update. My goal is to run this in directories with different versions of the same files with "diff -r" so that I can detect unexpected version differences.

+4
source share
2 answers

It works:

 $ sed -e 's/who/what/g' -e 's/fido/kitty/g' /etc/services | diff - /etc/services 38c38 < whatis 43/tcp nicname --- > whois 43/tcp nicname 183c183 < what 513/udp whatd --- > who 513/udp whod 568c568 < binkp 24554/tcp # binkp kittynet protocol --- > binkp 24554/tcp # binkp fidonet protocol ... 

If your sed script will be created by the program (and will have stronger regular expressions).

+2
source

diff version I have (GNU diffutils 2.8.1) supported diff -I :

 -I RE --ignore-matching-lines=RE Ignore changes whose lines all match RE. 

This may not be exactly what you want, but in the specific case in your question diff -I'/path/to/something/ver[12]/blah/blah' it seems like it should work, although I'm not sure that it really works when I test it.

+1
source

Source: https://habr.com/ru/post/1309370/


All Articles