bash diff 命令忽略新目录中的新文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11369559/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 02:41:21  来源:igfitidea点击:

diff command ignoring new file in the new directory

linuxbashshelllinux-kernel

提问by user1427180

I added a new file in "modified directory" (in 3rd sub level folder) and when i try to generate the patch file using the following command it appears that diff command is ignoring the new file:

我在“修改后的目录”(在第三个子级别文件夹中)添加了一个新文件,当我尝试使用以下命令生成补丁文件时,diff 命令似乎忽略了新文件:

diff –ur "original directory" "modified directory" > version1.patch

I appreciate your help..

我感谢您的帮助..

采纳答案by Employed Russian

You also need -Nflag. From man diff:

您还需要-N标志。来自man diff

   -N  --new-file
          Treat absent files as empty.

When generating patches, the "standard" diff flags are -Npur. You've already discovered why you need -N; -pmakes the patch easier for humans to read.

生成补丁时,“标准”差异标志是-Npur. 你已经发现你为什么需要-N-p使补丁更易于人类阅读。

回答by LKL

Try with this command,

试试这个命令,

diff -RuN "original directory" "modified directory" > version.patch

diff -Run “原始目录” “修改后的目录” > version.patch