标签:diff
1, diff -u用于一体化输出:
ubuntu@VM-62-13-ubuntu:~$ diff -u v1 v2 --- v1 2015-06-27 20:43:50.530653196 +0800 +++ v2 2015-06-27 20:43:53.530653196 +0800 @@ -1,7 +1,7 @@ 4 3 2 -5 +4 7 7 -8 + ubuntu@VM-62-13-ubuntu:~$其中,以 + 起始的是新加入的行,以- 起始的是删除的行。
2, patch文件可以通过diff的输出重定向到一个文件来生成:
ubuntu@VM-62-13-ubuntu:~$ diff -u v1 v2 >v.path
ubuntu@VM-62-13-ubuntu:~$ patch -p1 v1 <v.patch patching file v1
ubuntu@VM-62-13-ubuntu:~$ diff v1 v2 ubuntu@VM-62-13-ubuntu:~$
ubuntu@VM-62-13-ubuntu:~$ patch -p1 v1 < v.patch patching file v1 ubuntu@VM-62-13-ubuntu:~$ diff v1 v2 4c4 < 5 --- > 4 7c7 < 8 --- > ubuntu@VM-62-13-ubuntu:~$
ubuntu@VM-62-13-ubuntu:~$ diff -Naur v1v v2v diff -Naur v1v/v1 v2v/v1 --- v1v/v1 2015-06-27 21:04:02.550408195 +0800 +++ v2v/v1 1970-01-01 08:00:00.000000000 +0800 @@ -1,7 +0,0 @@ -4 -3 -2 -5 -7 -7 -8 diff -Naur v1v/v2 v2v/v2 --- v1v/v2 1970-01-01 08:00:00.000000000 +0800 +++ v2v/v2 2015-06-27 21:04:07.998408195 +0800 @@ -0,0 +1,7 @@ +4 +3 +2 +4 +7 +7 + ubuntu@VM-62-13-ubuntu:~$
标签:diff
原文地址:http://blog.csdn.net/qinchaowhut/article/details/46663893