Reputation: 737
How can I exlude the following line in unix diff?
<xs:element attribute1="0" attribute2="return" attribute3="true" type="ax277:ResponseDataBean"/>
I need to exclude all cases where the number after 'ax' is different. For example, the following diff should be excluded:
File 1:
<xs:element attribute1="0" attribute2="return" attribute3="true" type="ax277:ResponseDataBean"/>
File 2:
<xs:element attribute1="0" attribute2="return" attribute3="true" type="ax111:ResponseDataBean"/>
I have tried:
diff -I 'type="ax^' file1 file2
But it is still displaying those lines.
Upvotes: 0
Views: 90
Reputation: 62369
You should really use XML tools for handling XML, because it's not going to be long before you find one of those files that was written with a line break in a place you don't expect it, making your line that you want to exclude no longer match a single-line pattern.
However, one way to do what you are asking would be to exclude those lines from the input that diff
considers to begin with. Something along these lines, using bash
process substitution:
diff <(grep -v 'type="ax[0-9]+:' file1) <(grep -v 'type="ax[0-9]+:' file2)
Upvotes: 1