tags:

views:

70

answers:

2

When using Diff, how would one go about ignoring line differences that only diff on GUID's? Something along the lines of:

diff -I "^.*[a-zA-Z0-9]{8}\-[a-zA-Z0-9]{4}\-[a-zA-Z0-9]{5}\-[a-zA-Z0-9]{5}\-[a-zA-Z0-9]{12}.*$"

Where obviously the above doesn't work, but just to get an idea of what is needed.

A: 

Can you pipe the output of diff to a grep -v and use your pattern?

Dave Webb
A: 

Perhaps you could first pipe the input files through sed to remove anything matching a GUID, then perform the diff.

Adam Batkin
This will run you into problems when doing a unified diff, because the GUID-less line might still appear in the diff, leading to conflicts when applying the diff later. If there are lines that don't (only) diff on the GUID, but other content, this method will lead to problems no matter what kind of diff you make.
balpha
I'm not sure if you are commenting on my specific answer or the original question in general, since any solution would have trouble applying a patch generated from such a diff. Plus the original question didn't specify that it was necessary to be able to generate a patch to apply later (there are plenty of other reasons one might want to find the difference between two files).
Adam Batkin