tags:

views:

45

answers:

1

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

E.g.

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"

This should show only show me that line 3 is different

Does anyone know of a good way to do that? I can easily write a perl script to do it but i will end up re-implementing most of the rest of the functionality of 'diff'.

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

+1  A: 

This 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
...

Where your sed script would be constructed by a program (and have stronger regexps).

msw
Yep I thought about that but the problem is that I actually need to run it on directories of files recursively. Will update the question.
That doesn't change the nature of the per-file task, which - recursive or not - needs to handle a single file before it handles all files.
msw