生成patch:
diff -ruN old new
比如:
diff -urN old new > 1.patch
打补丁:
命令很简单:
patch -p0 < 1.patch
但是怎么打还是问题:
1. 什么目录下打补丁?什么目录下可以打补丁?
2.在第几层打目录?
举几个例子来帮助理解一下:
在当前目录下创建如下的机构:
$mkdir new $mkdir old $echo "hello" > old/1.log $ls -al new old new: total 0 drwxr-xr-x 2 jason staff 68 Apr 11 09:56 . drwxr-xr-x 6 jason staff 204 Apr 11 09:56 .. old: total 8 drwxr-xr-x 3 jason staff 102 Apr 11 09:56 . drwxr-xr-x 6 jason staff 204 Apr 11 09:56 .. -rw-r--r-- 1 jason staff 6 Apr 11 09:56 1.log
在当前目录下使用diff比较
$ diff -ruN old new diff -ruN old/1.log new/1.log --- old/1.log 2017-04-11 09:56:59.000000000 +0800 +++ new/1.log 1970-01-01 08:00:00.000000000 +0800 @@ -1 +0,0 @@ -hello