In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
How to use patch files in Linux, I believe many inexperienced people are at a loss about this. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
The function of diff is to compare the differences between the two files, and then record it, that is, the so-called diff patch, patch is the use of diff patches to achieve the conversion of source files (folders) and destination files (folders).
The use of patch File under linux
Patches are generated by the diff tool and patched by the patch tool. Before using diff, you need to keep an unmodified copy of the source code and then modify a copy of the source code elsewhere. Diff compares the two source codes to generate patch. The modified source code must retain the original file name, for example, if you modify the A.C file in the source code, then the modified file is still named A.C, and you can copy A.C for a.orig.c before modification.
The command diff generates patch $diff-up linux-2.6.28.8/net/sunrpc/svc.orig.c linux-2.6.28.8/net/sunrpc/svc.c > xx.patch produces output similar to the following, which you redirect to a file called patch.
1 diff-up linux-2.6.28.8/net/sunrpc/svc.orig.c 2009-03-17 008 linux-2.6.28.8/net/sunrpc/svc.c 50 svc_process 04.000000000 + 0800 2 + linux-2.6.28.8/net/sunrpc/svc.c 2009-03-30 19 linux-2.6.28.8/net/sunrpc/svc.c 41.859375000 + 0800 3 @ @-1050 svc_process 11 + 1050 rqstp 11 @ @ svc_process (context)-u shows a few lines before and after the difference lines (context), the default is 3 lines before and after each line, so there is more information in the patch. -p displays information about the c function in which the code is located.
When generating patches for multiple files, usually organize multiple files in the source file directory and the new file directory respectively, and then use the diff command to generate the patch
The command $diff-uprN linux-2.6.28.8.orig/net/sunrpc/ linux-2.6.28.8/net/sunrpc/ > patch compares all source code differences between linux-2.6.28.8.orig/net/sunrpc/ and linux-2.6.28.8/net/sunrpc/. Parameter description:-r recursively compares a directory with all its subdirectories (that is, the entire directory tree). -N if a file is missing, compare it as an empty file. If you do not use this option, when diff finds that the old code or new code is missing a file, it simply prompts that the file is missing. If you use this option, the newly added files will be newly printed as a new part.
The patch generated by the patch contains the path information. When making the patch, you need to check the patch file, usually the first line, to check that the patch file is contained in several layers of directories, and then corresponding to the-p of the patch command, and the number after-p indicates ignoring several layers of directories.
Patch-p1 after reading the above, have you mastered how to use the patch file in Linux? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.