[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.