Linux patch命令


  翻译结果:

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,Thisisthefirstfile!  
---  
>Hello,Thisisthesecondfile!  #将比较结果保存到tetsfile.patch文件  
$ diff testfile1 testfile2>testfile.patch     
$ cat testfile.patch                #查看补丁包的内容  
1c1  
<Hello,Thisisthefirstfile!  
---
>Hello,Thisisthesecondfile!  #使用补丁包升级testfile1文件  
$ patch -p0 testfile1 testfile.patch      
patching file testfile1  
$cat testfile1                  #再次查看testfile1的内容  
#testfile1文件被修改为与testfile2一样的内容  
Hello,This is the secondfile!

热门推荐

目录

首页

视频

问答