@breakerthb
2016-07-06T07:24:29.000000Z
字数 844
阅读 1535
Linux
Shell
old.txt
111
222
333
444
555
666
777
888
999
000
new.txt
111
1.5
222
2.5
2.6
333
444
555
888
909
000
$ diff old.txt new.txt
1a2 在old第1行之后加入了new的第2行
2a4,5在old第2行之后加入了new的第4,5行
9c10old中第9行修改为new第10行
<表示old文件中的内容
>表示new文件中的内容
6,7d8old第6、第7行原本在new第8行之后
$ diff old.txt new.txt -y -W 50
$ diff old.txt new.txt -c
Output NUM (default 3) lines of copied context.
$ diff old.txt new.txt -u
'-'表示old.txt
'+'表示new.txt
'-1,10' old.txt的前10行
'+1,10' new.txt的前11行
$ diff path1 path2
PS : 给目录打补丁会发生覆盖
$ diff -ruN old.txt new.txt > log.patch
$ cat log.patch
$ patch -p0 < log.patch
patching file old.txt
去掉默认路径中的NUM个‘/
如果恢复打补丁之前的文件
$ patch -RE -p0 < log.patch