patch
英[p?t?]? ?美[p?t?]??
n.補(bǔ)丁,補(bǔ)片;眼罩;斑點(diǎn);小塊
vt .修補(bǔ),拼湊;暫時(shí)遮掩一下;修理,平息(吵架等);用美人斑裝飾(臉)
vi.打補(bǔ)丁
第三人稱單數(shù): patches 複數(shù): patches 現(xiàn)在分詞: patching 過(guò)去式: patched 過(guò)去分詞: patched
Linux patch指令 語(yǔ)法
作用:patch指令用於修補(bǔ)檔案。這是Linux系統(tǒng)核心的升級(jí)方法之一。
語(yǔ)法: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指令 範(fàn)例
使用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!