patch

英[pætʃ] 美[pætʃ]

n. patch, patch; eye patch; spot; small piece

vt .patch, piece together; temporarily cover up; repair, calm (quarrel, etc.); decorate (face) with beauty spots

vi.patch

Third person singular: patches Plural: patches present participle : patching past tense: patched past participle: patched

Linux patch command syntax

Function:patch command is used to patch files. This is one of the core upgrade methods of Linux system.

Syntax:patch [-bceEflnNRstTuvZ][-B ][-d ][-D ;][-F ][-g ][-i ][-o ][-p ][-r ][-V ][-Y ][-z ] [--backup-if -mismatch][--binary][--help][--nobackup-if-mismatch][--verbose][original file] or path [-p < Strip layers>] < [Patch file]

Linux patch command example

Use the patch command to upgrade the file "testfile1". The upgrade patch file is "testfile.patch". Enter the following command:

$ patch -p0 testfile1 testfile.patch #使用补丁程序升级文件

Before using this command, you can use the command "cat" to view "testfile1" "Content. Use the pointer

令"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!
between the file that needs to be modified and upgraded and the original file.