使用bash根据md5查找重复文件

use*_*020 6 bash shell

我想写一个关于bash的算法,它找到了重复的文件

如何添加尺寸选项?

小智 13

find . -not -empty -type f -printf "%s\n" | sort -rn | uniq -d |\
xargs -I{} -n1 find . -type f -size {}c -print0 | xargs -0 md5sum |\
sort | uniq -w32 --all-repeated=separate
Run Code Online (Sandbox Code Playgroud)

这就是你想要的方式.首先根据大小找到dup,然后是MD5哈希.请注意与您的问题相关的-size的使用.请享用.假设您要在当前目录中搜索.如果没有,请更改"查找".适合您要搜索的目录.


Gil*_*not 12

不要重新发明轮子,使用正确的命令:

fdupes -r dir
Run Code Online (Sandbox Code Playgroud)

请参阅http://code.google.com/p/fdupes/(打包在某些Linux发行版上)

  • `fdupes` 有相当严重的性能问题。我试图找到大约 200 个非常大的视频文件的欺骗内容。`fdupes` 花了大约一个小时来扫描它。我的脚本做了一些简单的技巧,花了大约 4 分钟。 (3认同)