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.