Use of diff and patch

Source: Internet
Author: User

In Linux system programming, diff and patch generation patches and patching are often used. It is difficult to understand diff and patch generation. Once it is done, it cannot be found.

1. Use diff to generate patches;

Diff is a file comparison command in Linux. The parameter is not mentioned here. Just use man to compare files and two directories, in addition, patch files can be generated based on differences, which is actually a patch command. The usage is as follows:

Diff-rnu a B> diff. Patch

Here, a is the old directory or file, B is the recently modified directory or file, and the patch file generated is patch.


2. patch the patch;

For the parameters of the patch command, see the man manual. Patch is used to patch another directory A as follows:
Patch-P0 <diff. Patch

In this way, if the patch cannot be completed, it is saved as the "*. rej" file.

Blog: http://wuquan-1230.blog.163.com/blog/static/29811153201172923038674/

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.