递归查找重复文件(bash4,关联数组)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了递归查找重复文件(bash4,关联数组)相关的知识,希望对你有一定的参考价值。
# bash4 - Use Associative Arrays to find duplicate files. # Generate a file "rmdups" which contains rm commands to remove the duplicates. # Check this file and then source it from the current (!) directory # to actually remove the duplicates. Works equally with the (deprecated) # md5sum program instead of sha*sum. unset flist; declare -A flist while read -r sum fname; do if [[ ${flist[$sum]} ]]; then printf 'rm -- "%s" # Same as >%s< ' "$fname" "${flist[$sum]}" else flist[$sum]="$fname" fi done < <(find . -type f -exec sha256sum {} +) >rmdups
以上是关于递归查找重复文件(bash4,关联数组)的主要内容,如果未能解决你的问题,请参考以下文章