Linux 目录对比

来自三线的随记

Method 1

find directory1 -printf "%P\n" | sort > file1

find directory2 -printf "%P\n" | sort | diff file1 -


Method 2

diff <(tree -Ci --noreport /directory1) <(tree -Ci --noreport /directory2)


Method 3

diff -r directory1 directory2

但是diff会对每个文件中的每一行都做比较,所以文件较多或者文件较大的时候会非常慢。请谨慎使用。