Skip to content

Instantly share code, notes, and snippets.

@yrgoldteeth
Created September 27, 2015 05:15
Show Gist options
  • Select an option

  • Save yrgoldteeth/07e4418482086adad970 to your computer and use it in GitHub Desktop.

Select an option

Save yrgoldteeth/07e4418482086adad970 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Check for duplicate files using an associative array indexed with the SHA sum of the files
unset flist; declare -A flist;
while read -r sum fname; do
if [[ ${flist[$sum]} ]]; then
printf 'rm -- "%s" # Same as >%s<\n' "$fname" "${flist[$sum]}"
else
flist[$sum]="$fname"
fi
done < <(find . -type f -exec sha256sum {} +) >rmdups
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment