patch
英[p?t?]? ?美[p?t?]??
n.補丁,補片;眼罩;斑點;小塊
vt .修補,拼湊;暫時遮掩一下;修理,平息(吵架等);用美人斑裝飾(臉)
vi.打補丁
第三人稱單數(shù): patches 複數(shù): patches 現(xiàn)在分詞: patching 過去式: patched 過去分詞: patched
Linux patch指令 語法
作用:patch指令用於修補檔案。這是Linux系統(tǒng)核心的升級方法之一。
語法:patch [-bceEflnNRstTuvZ][-B <備份前綴字串>][-d <工作目錄>][-D <標示符號> ;][-F <監(jiān)別列數(shù)>][-g <控制數(shù)值>][-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 "的內(nèi)容。在需要修改升級的檔案與原始檔案之間使用指
令"diff"比較可以生成補丁文件。具體操作如下所示: $ cat testfile1 #查看testfile1的內(nèi)容 Hello,This is the firstfile! $ cat testfile2 #查看testfile2的內(nèi)容 Hello,Thisisthesecondfile! $ diff testfile1 testfile2 #比較兩個文件 1c1 <Hello,Thisisthefirstfile! --- >Hello,Thisisthesecondfile! #將比較結(jié)果保存到tetsfile.patch文件 $ diff testfile1 testfile2>testfile.patch $ cat testfile.patch #查看補丁包的內(nèi)容 1c1 <Hello,Thisisthefirstfile! --- >Hello,Thisisthesecondfile! #使用補丁包升級testfile1文件 $ patch -p0 testfile1 testfile.patch patching file testfile1 $cat testfile1 #再次查看testfile1的內(nèi)容 #testfile1文件被修改為與testfile2一樣的內(nèi)容 Hello,This is the secondfile!