Diff and patch

Source: Internet
Author: User

[This article is Android embedded Learning Series II]

Objectives:

Understand how to use diff and patch, learn how to create a new file through an instance, and how to Append content to an existing file

In software development, a diff file is often output before submission to check the changes to the following code. For example, git diff is the same when git is used.

Diff and Patch are useful in shell commands.

Familiarize yourself with the following through the instance;

// Create a new source file echo "Hello diff"> testdiff // copy and modify CP testdiff tesdiff1echo-e "APPEND some text: \ n Hello :) "> testdiff1 // generate the patch file diff testdiff testdiff1> diff. patch

If testdiff1 is a new file we have modified, we can fix it and merge the testdiff1 changes into the testdiff file,

// Merge patch-po diff. Patch

In this way, the content in testdiff will be consistent with that in testdiff1.

Summary:

In the above example, the new file is implemented through the output ">" in the shell. ECHO can output the content on the screen, in combination with the output character, the text is written to the testdiff file, and the file does not exist, so a new one is created.

Next, CP implements file replication and uses echo to output text again. The option "-e" indicates that escape characters are supported, and ">" is used to append the text to the end.

Similarly, diff is generated and output to the file, and patch the file with patch.

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.