patch

English [p?t?] US [p?t?]

n. ??, ??; ?? ??

vt. ??, ????? ??; .); ?? ?? ??(??) ??

vi. patch

3?? ??: ?? ??: ?? ?? ??: ?? ?? ??: ??: ??

??? ?? ?? ???

??: patch ??? ??? ???? ? ?????. ?? Linux ???? ?? ????? ?? ? ?????.

??: ??patch [-bceEflnNRstTuvZ][-B <?? ??? ???>][-d <?? ????>][-D <?? ??>][-F <? ? ????>] [-g ][-i ][-o ][-p ][-r ][-V <; ?? ??>][-Y ][-z ][--backup-if -mismatch ][--binary][--help][--nobackup-if- ???][--verbose][?? ??<?? ??>] ?? ?? [-p <??? ???>] < [ ?? ??]

??? ?? ?? ?

?? ??? ???? "testfile1" ??? ????????. ????? ?? ??? "testfile.patch"???. ?? ??? ?????.

$ patch -p0 testfile1 testfile.patch    #使用補(bǔ)丁程序升級(jí)文件

? ??? ???? ?? "cat" ??? ???? ??? ? ? ????. "?????1". ?? ? ?????? ??? ??? ?? ?? ??? ???

令"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!
? ?????.