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

前端 未结 15 2269
借酒劲吻你
借酒劲吻你 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-02 06:25

    You can use:

    diff -u f1 f2 |colordiff |diff-highlight
    

    colordiff is a Ubuntu package. You can install it using sudo apt-get install colordiff.

    diff-highlight is from git (since version 2.9). It is located in /usr/share/doc/git/contrib/diff-highlight/diff-highlight. You can put it somewhere in your $PATH.

提交回复
热议问题