I would like to use diff
to compare two directories for differing files, using the -q
option for brief output. However, the output is cluttered with a lot of files that only exist in one directory, but not the other. Can I force diff
(or use another tool) to only show files that differ AND exist in both directories?
我想使用diff来比较不同文件的两个目录,使用-q选项进行简短输出。但是,输出混乱了许多只存在于一个目录中但不存在于另一个目录中的文件。我可以强制差异(或使用其他工具)只显示两个目录中存在的文件吗?
The current command I use is
我使用的当前命令是
diff -q <dir1> <dir2>
Any ideas are appreciated.
任何想法都表示赞赏。
2 个解决方案
#1
16
It prints a bunch of lines like
它打印出一堆像
Only in dir1/blah: blah
right? So just throw them away with grep.
对?所以用grep将它们扔掉。
LC_ALL=C diff ... | grep -v '^Only in'
The LC_ALL=C
is to make sure that the standard "Only in" message will be printed, not any translation.
LC_ALL = C是为了确保打印标准的“仅在”消息,而不是任何翻译。
#2
-4
Easiest way I found is to use:
我找到的最简单的方法是使用:
diff -N -q <dir1> <dir2>
#1
16
It prints a bunch of lines like
它打印出一堆像
Only in dir1/blah: blah
right? So just throw them away with grep.
对?所以用grep将它们扔掉。
LC_ALL=C diff ... | grep -v '^Only in'
The LC_ALL=C
is to make sure that the standard "Only in" message will be printed, not any translation.
LC_ALL = C是为了确保打印标准的“仅在”消息,而不是任何翻译。
#2
-4
Easiest way I found is to use:
我找到的最简单的方法是使用:
diff -N -q <dir1> <dir2>