Linux diff and patch

Source: Internet
Author: User
Tags diff patch


Linux diff and patch diff have many options, but here we only introduce the three most commonly used. For other options, let's look at man diff:-r: recursively comparing files in folders-N: if a comparative file does not exist, it is regarded as an empty file-u: uniied. The result of diff is formatted and output (more readable) www.2cto.com. Therefore, diff is generally used as follows: diff-Nur old_version new_version> mods. diff patch uses the output of the diff file, so the two are always paired. However, patch not only supports diff output, but also supports diff generated by tools such as svn/git. Three common options of patch:-p NUM: The generated diff file, which contains the path of the to-file (old_version above) used in diff. The path has a level, for example: /myproject/model/people/profile. py, but this path is not always correct, because the location of the diff file can be moved, for example, in the/directory, it is no problem to patch by path, however, if the diff file is saved in the/myproject directory,/myproject/model/people/profile cannot be found. py path. This-p attribute is used to remove the number of slash (/) in the path. By default, path is profile. py. -P1: myproject/model/people/profile. py. -P2: model/people/profile. py. -P3: people/profile. py. -P4: profile. py. Therefore, patch-p0 is different from patch. -R: -- reverse. patch has been applied. If you want to cancel a patch, add this option-B: to back up the patch file, for example, to profile. patch the py file. after hitting the file, you will find one more hello. py. general Usage of orig file patch: patch-pNUM <patchfile, NUM depends on the specific situation.

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.