Skip to content

Instantly share code, notes, and snippets.

@zhiyb
Created April 2, 2018 03:40
Show Gist options
  • Select an option

  • Save zhiyb/0bda5662fa8bbbc311ed6450e203f163 to your computer and use it in GitHub Desktop.

Select an option

Save zhiyb/0bda5662fa8bbbc311ed6450e203f163 to your computer and use it in GitHub Desktop.
Find files with the same sha1sum
#!/bin/bash
declare -a sum file
cksum="$(eval sha1sum $(find . -type f -printf '"%p"\n'))"
sum=($(echo "$cksum" | cut -d\ -f 1))
eval file=($(echo "$cksum" | cut -d\ -f 3- | awk '{print "\""$0"\""}'))
for ((i=1;i<${#sum[@]};i++)); do
for ((j=0;j<i;j++)); do
if [ "${sum[i]}" == "${sum[j]}" ]; then
echo "${sum[i]} | ${file[i]} | ${file[j]}" #; rm "${file[i]}"
break 1
fi
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment