patch
英 [pætʃ] 美 [pætʃ]
n.补丁,补片;眼罩;斑点;小块
vt.修补,拼凑;暂时遮掩一下;修理,平息(吵架等);用美人斑装饰(脸)
vi.打补丁
第三人称单数: patches 复数: patches 现在分词: patching 过去式: patched 过去分词: patched
Linux patch命令 语法
作用:patch命令用于修补文件。这是Linux系统核心的升级方法之一。
语法:patch [-bceEflnNRstTuvZ][-B ][-d ][-D ][-F ][-g ][-i ][-o ][-p ][-r ][-V ][-Y ][-z ][--backup-if -mismatch][--binary][--help][--nobackup-if-mismatch][--verbose][原始文件 ] 或 path [-p ] < [修补文件]
Linux patch命令 示例
使用patch指令将文件"testfile1"升级,其升级补丁文件为"testfile.patch",输入如下命令:$ patch -p0 testfile1 testfile.patch #使用补丁程序升级文件
使用该命令前,可以先使用指令"cat"查看"testfile1"的内容。在需要修改升级的文件与原文件之间使用指令"diff"比较可以生成补丁文件。具体操作如下所示:
$ cat testfile1 #查看testfile1的内容
Hello,This is the firstfile!
$ cat testfile2 #查看testfile2的内容
Hello,Thisisthesecondfile!
$ diff testfile1 testfile2 #比较两个文件
1c1
---
>Hello,Thisisthesecondfile! #将比较结果保存到tetsfile.patch文件
$ diff testfile1 testfile2>testfile.patch
$ cat testfile.patch #查看补丁包的内容
1c1
---
>Hello,Thisisthesecondfile! #使用补丁包升级testfile1文件
$ patch -p0 testfile1 testfile.patch
patching file testfile1
$cat testfile1 #再次查看testfile1的内容
#testfile1文件被修改为与testfile2一样的内容
Hello,This is the secondfile!