diff
(1)文件之间的差异对比
diff file1 file2 比较
-u 显示所有内容及差异
diff -u file1 file2 > file1-to-file2.patch生成补丁
(2)比较文件夹
diff dir1 dir2
-uNr 一般所加参数
diff -uNr dir1 dir2 > dir1-to-dir2.patch 生成补丁
patch 打补丁命令
(1)对文件打补丁
patch file1 < file1-to-file2.patch
-R 撤销打补丁
(2)目录打补丁
diff -uNr dir1 dir2 > dir1-to-dir2.patch 生成补丁
cd dir1 进入需要打补丁的文件夹
patch -p1 < file1-tofile2.path 打补丁。-p1参数去掉第一层目录进行打补丁
patch -R -p1 < file1-tofile2.path 撤销打补丁
总结:
(1)不管对于文件还是文件夹打补丁时,首先进入需要打补丁的文件和文件所在的目录
#cd /tmp/diff_test
(2) 将补丁文件复制到目录下
#cp /f1-to-f2.patch /tmp/emp/diff_test
(3) 打补丁
#patch -p0 < f1-to-f2.patch
(4) 恢复到原来版本
#patch -RE -p0 < f1-to-f2.patch
需要注意的是一个路径问题