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/