How to ignore some differences in diff command?

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

    My open-source Linux tool 'dif' compares files while ignoring various differences.

    It has many options for doing search/replace, ignoring whitespace, comments, or timestamps, sorting the input files, ignoring certain lines, etc.

    After preprocessing the input files, it runs the Linux tools meld, gvimdiff, tkdiff, diff, or kompare on these intermediate files.

    Installation is not required, just download and run the 'dif' executable from https://github.com/koknat/dif

    For your use case, try the search and replace option:

    ./dif file1 file2 -search 'ab[XY]d' -replace 'abd' -diff
    

提交回复
热议问题