How to ignore some differences in diff command?

前端 未结 5 899
情书的邮戳
情书的邮戳 2021-02-06 23:13

diff has an option -I regexp, which ignores changes that just insert or delete lines that match the given regexp. I need an analogue of this for the ca

5条回答
  •  甜味超标
    2021-02-06 23:31

    Improving upon the earlier solution by John Kugelman:

    diff <(sed 's/ab[XY]d/abd/g' file1) <(sed 's/ab[XY]d/abd/g' file2)
    

    is probably what you may be looking for! This version normalizes the specific change on each line without deleting the line itself. This allows diff to show any other differences that remain on the line.

提交回复
热议问题