patch
英 [p?t?]? ?美 [p?t?]??
n.補(bǔ)丁,補(bǔ)片;眼罩;斑點(diǎn);小塊
vt.修補(bǔ),拼湊;暫時(shí)遮掩一下;修理,平息(吵架等);用美人斑裝飾(臉)
vi.打補(bǔ)丁
第三人稱單數(shù): patches 復(fù)數(shù): patches 現(xiàn)在分詞: patching 過去式: patched 過去分詞: patched
Linux patch命令 語法
作用:patch命令用于修補(bǔ)文件。這是Linux系統(tǒng)核心的升級(jí)方法之一。
語法:patch [-bceEflnNRstTuvZ][-B <備份字首字符串>][-d <工作目錄>][-D <標(biāo)示符號(hào)>][-F <監(jiān)別列數(shù)>][-g <控制數(shù)值>][-i <修補(bǔ)文件>][-o <輸出文件>][-p <剝離層級(jí)>][-r <拒絕文件>][-V <備份方式>][-Y <備份字首字符串>][-z <備份字尾字符串>][--backup-if -mismatch][--binary][--help][--nobackup-if-mismatch][--verbose][原始文件 <修補(bǔ)文件>] 或 path [-p <剝離層級(jí)>] < [修補(bǔ)文件]
Linux patch命令 示例
使用patch指令將文件"testfile1"升級(jí),其升級(jí)補(bǔ)丁文件為"testfile.patch",輸入如下命令:
$ patch -p0 testfile1 testfile.patch #使用補(bǔ)丁程序升級(jí)文件
使用該命令前,可以先使用指令"cat"查看"testfile1"的內(nèi)容。在需要修改升級(jí)的文件與原文件之間使用指
令"diff"比較可以生成補(bǔ)丁文件。具體操作如下所示: $ cat testfile1 #查看testfile1的內(nèi)容 Hello,This is the firstfile! $ cat testfile2 #查看testfile2的內(nèi)容 Hello,Thisisthesecondfile! $ diff testfile1 testfile2 #比較兩個(gè)文件 1c1 <Hello,Thisisthefirstfile! --- >Hello,Thisisthesecondfile! #將比較結(jié)果保存到tetsfile.patch文件 $ diff testfile1 testfile2>testfile.patch $ cat testfile.patch #查看補(bǔ)丁包的內(nèi)容 1c1 <Hello,Thisisthefirstfile! --- >Hello,Thisisthesecondfile! #使用補(bǔ)丁包升級(jí)testfile1文件 $ patch -p0 testfile1 testfile.patch patching file testfile1 $cat testfile1 #再次查看testfile1的內(nèi)容 #testfile1文件被修改為與testfile2一樣的內(nèi)容 Hello,This is the secondfile!