简单学习下patch
时间:2010-10-16 来源:linux_2003
先简单说下linux下创建一个patch文件,以鸟哥的私房菜为参考吧。
一般用命令 diff -Naur passwd.old passwd.new >passwd.patch
说下diff的几个参数,好像鸟哥对此没做详述。
man diff
-N
--new-file
In directory comparison, if a file is found in only one directory, treat it
as present but empty in the other directory.
Google了下很多人是这么翻译的
在比较目录时,若文件A仅出现在某个目录中,预设会显示:Only in目录;文件A若使用-N参数,则diff会将文件A与一个空白的文件比较。
我做了下测试发现是这样的:比较目录时,如果找到一个文件仅仅出现在1个目录中时,会把它与另一个目录中的0文件进行比较,也就是与另一个目录中的一个空白文件进行比较。并且显示这个文件的内容,否则不显示它的内容 。可见上面的翻译还是对的。
真没看出这个参数的意义究竟是啥来。跟不存在的文件比较有啥意思啊。
-a Treat all files as text and compare them line-by-line, even if they do not seem to be text.
对待所有的文件就像文本文件一行一行的处理,甚至于当他们(处理的文件)不是文本格式。
-u Use the unified output format.
使用统一的输出格式。
-r When comparing directories, recursively compare any subdirectories found.
递归查找子目录。
最后patch -d (指定更新的目录) -pN <patch
N 就是去掉几个'/' ,什么?不明白。哦,请看鸟哥吧。^_^