用于确定目录“diff”的脚本
我有两个目录,它们是同一软件包的不同版本。我想列出两者之间已更改的所有文件/目录,然后将这些差异复制到新目录。
我一直在使用 md5sum
和 diff -Nurq
尝试不同的脚本,但无法获得我正在寻找的结果。
有什么建议吗?
编辑:
我最初尝试使用md5sum
,但这似乎不起作用,尤其是在新文件丢失的情况下。
接下来我尝试了这样的循环:
for x in `diff -Nurq ./dir1/ ./dir2/ | awk -F" " '{print $4}'`
do
mkdir -vp ./dir_1_2_upgrade/$x;
cp $x ./dir_1_2_upgrade/$x
done
但最终生成了一堆目录而没有文件。
I have two directories which are different versions of the same software package. I'd like to list all the files/directories that have changed between the two then copy those differences to a new directory.
I've been trying different scripts with md5sum
and diff -Nurq
but haven't been able to get the result I'm looking for.
Any recommendations?
Edit:
I originally tried taking md5sum
s, but that didn't seem to work especially if new files were missing.
Next I tried a loop like this:
for x in `diff -Nurq ./dir1/ ./dir2/ | awk -F" " '{print $4}'`
do
mkdir -vp ./dir_1_2_upgrade/$x;
cp $x ./dir_1_2_upgrade/$x
done
But that ended up making a bunch of directories and no files.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果文件名不包含空格,则有效。如果您希望它尽可能通用,请查看程序的源代码,例如
git-diff
。works if filenames contain no spaces. If you want this to be as general as possible, check out the source for a program such as
git-diff
.