The patch patch command is used

Source: Internet
Author: User

The patch patch command is used

Http://www.cnblogs.com/huanghuang/archive/2011/07/14/2106402.html


Patch commands are used for patching, and patch files are generated using diff
Patch command syntax

Patch [-B [-B Prefix]] [-F] [-l] [-N] [-R] [-S] [-V] [-C |-e |-n] [-D Directory] [-D Define] [-F number] [-I. Patchfile] [-O OutFile] [-P number] [-  R Rejectfile] [-X number] [File]

When a patch command fails or refuses to accept patches, it produces a diff file with the same name as the original file, with a suffix of ". Rej".
When using-B, a backup file with the same name as the original file with a suffix of ". Orig" is generated.

Frequently used patch parameters:
-P: Specify the directory level (remove a few levels from the path name) if the patch file contains the path names/CURDS/WHEY/SRC/BLURFL/BLURFL.C
Then:-P 0 uses the full path name-P 1 To remove the leading slash, leaving the CURDS/WHEY/SRC/BLURFL/BLURFL.C. -P 4 Removes the leading slash and the first three directories, leaving the BLURFL/BLURFL.C.

-d:directory change the current directory to the specified directory before hitting the patch
-i:patchfile Specify patch files instead of reading patch information from standard input
-R: Reverse patch, this option is useful in preventing error patching

The generation of patches is typically compared with the diff command for a and B files

diff -nrua a b > C.patch

Such as:

diff -nrua linux-2.6. /makefile linux-2.6. /makefile >c.patchcat c.Patch

---linux-2.6.14/makefile 2008-07-30 16:54:20.000000000 +0800 + + linux-2.6.26/makefile 2008-07-14 05:51:29.000000000 + 0800 @@ -1,8 +1,8 @@ -1,8 = 2 Patchlevel = 6-sublevel = +sublevel = + extraversion =-name=affluent Albatross +nam E = Rotary Wombat # *documentation* # to see a list of typical targets execute ' make help '

---file represents a file that will be patched such as: Linux-2.6.14/makefile + + + file for patch source files such as: Linux-2.6.26/makefile

Application

ls c.Patch linux-2.6.  linux-2.6.  - CD Linux-2.6.  - Patch -P1 < /C.Patch

If you have multiple patches to play, you should pay attention to the order of patching!

Excerpt from: http://blog.ednchina.com/mcu_study/146725/message.aspx

The patch patch command is used

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.