Using 'diff' (or anything else) to get character-level diff between text files

前端 未结 15 2224
借酒劲吻你
借酒劲吻你 2020-12-02 05:40

I\'d like to use \'diff\' to get a both line difference between and character difference. For example, consider:

File 1

abcde
ab         


        
15条回答
  •  时光取名叫无心
    2020-12-02 06:16

    Python's difflib is ace if you want to do this programmatically. For interactive use, I use vim's diff mode (easy enough to use: just invoke vim with vimdiff a b). I also occaisionally use Beyond Compare, which does pretty much everything you could hope for from a diff tool.

    I haven't see any command line tool which does this usefully, but as Will notes, the difflib example code might help.

提交回复
热议问题