单个文件
diff –uN from-file to-file >to-file.patch
patch –p0 < to-file.patch 将from-file文件打补丁变成to-file文件
patch –RE –p0 < to-file.patch
多个文件
diff –uNr from-docu to-docu >to-docu.patch
patch –p1 < to-docu.patch 打补丁
patch –R –p1 <to-docu.patch 取消上次打的补丁
扩展:
patch -p[0-n] -s < dest_patch 使用patch,-s参数即silent,表示终端无信息输出
patch -p[0-n] --dry-run < dest_patch 只显示运行结果,不实际生效
另外,当patch命令检测到冲突时会弹出提示,还会生成一些.rej文件,可查看.rej文件来手动修改