Created
April 2, 2018 03:40
-
-
Save zhiyb/0bda5662fa8bbbc311ed6450e203f163 to your computer and use it in GitHub Desktop.
Find files with the same sha1sum
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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