Linux diff patch

Source: Internet
Author: User
Tags diff diff patch

/***************************************************************************** * Linux diff p Atch * Statement: * Often need to patch the code, but found that they do not patch, often look at the patch to change the code, efficiency * that is a low ah, will not learn Bai, anyway patch has-r fallback, not afraid of error. * 2015-12-28 Shenzhen Nanshan Ping Shan village Zengjianfeng ********************************************************* *******************/                    \\\\\\-*-Directory-*-//////|Reference article:|One, cat main1.c|second, cat main2.c|c. Execute diff:|iv. Execute Patch:|v. Patch back:-----------------------Reference article:1. Use diff and patch tools to maintain source http://www.ibm.com/developerworks/cn/linux/l-diffp/index.html    2. diff and Patch Usage guide http://www.cnblogs.com/cute/archive/2011/04/29/2033011.htmlone, cat main1.c #include<stdio.h>intMainintargcChar**argv) {printf ("ZENGJF test for diff and Patch.\n" ); } II, cat main2.c #include<stdio.h>intMainintargcChar**argv) {printf ("ZENGJF test for diff and Patch.\n" ); } III, execute diff:1. $: Diff-nur main1.c main2.c >Main.patch2The . main.patch file is generated under the current directory:---main1.c -- A- -  -: $:49.388152208+0800+ + main2.c -- A- -  -: -:17.376180914+0800        @@ -2,5+2,8 @@                  intMainintargcChar**argv) {        +        +        +printf ("ZENGJF test for diff and Patch.\n" ); } Four, execute Patch:1The current directory is: main1.c main2.c main.patch2. Cat main1.c #include<stdio.h>intMainintargcChar**argv) {printf ("ZENGJF test for diff and Patch.\n" ); }    3. $: patch-p0 < Main.patch <right>Patching file main1.c4. Cat main1.c #include<stdio.h>intMainintargcChar**argv) {printf ("ZENGJF test for diff and Patch.\n" ); }    5. $: Patch P0 < Main.patch <error>Patching file P0 Hunk #1FAILED at2. 1  outof hunk FAILED--saving rejects to file P0.rej6. $: Patch-p1 < Main.patch <error>can't find file to patch on input line 3Perhaps you used the wrong-p or--strip option?The text leading up to Thiswas :----------------------------------|---main1.c -- A- -  -: $:49.388152208+0800|---main2.c -- A- -  -: -:17.376180914+0800----------------------------------File to Patch:<cursor>7. $: patch-p0 main.patch <error> ^C v. Patch back:1The current directory is: main1.c main2.c main.patch2. Cat main1.c #include<stdio.h>intMainintargcChar**argv) {printf ("ZENGJF test for diff and Patch.\n" ); }    3. $: Patch-p0-r <main.patch Patching file main1.c4. Cat main1.c #include<stdio.h>intMainintargcChar**argv) {printf ("ZENGJF test for diff and Patch.\n" ); }

Linux diff patch

Related Article

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.