没有差异文件的差异文件夹

Jon*_*nah 2 linux

可能的重复:
Linux:比较目录结构而不比较文件

我正在比较两个文件夹树,但需要很长时间,因为它正在比较文件本身。我只想知道一棵树中有哪些文件夹/文件,而不是另一棵树。

做这个的最好方式是什么?

Gil*_*il' 7

使用find列出每个树中的文件,排序,然后使用diffcomm进行比较。鲜为人知的comm命令是一个专门的文件比较工具,它只是区分只出现在第一个文件中的行、只出现在第二个文件中的行和同时出现在两个文件中的行。

(cd /some/dir1 && find . | sort >/tmp/dir1.find)
(cd /where/dir2 && find . | sort >/tmp/dir2.find)
# Show the files that are in dir1 but not in dir2
comm -23 /tmp/dir1.find /tmp/dir2.find
# Show the files that are in dir2 but not in dir1
comm -13 /tmp/dir1.find /tmp/dir2.find
Run Code Online (Sandbox Code Playgroud)