centos中的2个文件夹:/folder1 and/folder2,每个文件夹中都有一些文件和子文件夹。
我使用以外的比较3来比较内容,但不知道如何同时比较文件模式和所有者。
感谢您的任何帮助!
如果不必一次完成所有操作,则可以首先diff <(cd /folder1; ls -lR) <(cd /folder2; ls -lR) | grep '^[<>]'
获取所有者/模式差异,然后获得diff -r /folder1 /folder2
以获取内容差异。
如果您真的希望一次完成所有操作,则可以为包括名称,所有者,模式和校验和比较两个目录的每个目录生成一个列表。这只会告诉您哪个文件不同,而不是其中的更改。
diff
<(find /folder1 -printf '%Pt%u:%gt%M' (
-type b -exec stat -c 'tb:%t:%Tn' -- '{}' ; -o
-type c -exec stat -c 'tc:%t:%Tn' -- '{}' ; -o
-type d -printf '/n' -o
-type p -printf '|n' -o
-type f -printf 't' -exec sum -- '{}' ; -o
-type l -printf 't-> %ln' -o
-type s -printf '=n' -o
-printf 't???n' ) | sort)
<(find /folder2 -printf '%Pt%u:%gt%M' (
-type b -exec stat -c 'tb:%t:%Tn' -- '{}' ; -o
-type c -exec stat -c 'tc:%t:%Tn' -- '{}' ; -o
-type d -printf '/n' -o
-type p -printf '|n' -o
-type f -printf 't' -exec sum -- '{}' ; -o
-type l -printf 't-> %ln' -o
-type s -printf '=n' -o
-printf 't???n' ) | sort) |
grep '^[<>]'