How to ignore some differences in diff command?

前端 未结 5 827
情书的邮戳
情书的邮戳 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:26

    You could filter the two files through sed to eliminate the lines you don't care about. The general pattern is /regex1/,/regex2/ d to delete anything between lines matching two regexes. For example:

    diff <(sed '/abXd/,/abYd/d' file1) <(sed '/abXd/,/abYd/d' file2)
    

提交回复
热议问题