Created
September 7, 2013 20:22
-
-
Save rwohleb/6478944 to your computer and use it in GitHub Desktop.
Perl dedupe script. http://unix.stackexchange.com/a/42195
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 | |
DIR="/path/to/big/files" | |
find $DIR -type f -exec md5sum {} \; | sort > /tmp/sums-sorted.txt | |
OLDSUM="" | |
IFS=$'\n' | |
for i in `cat /tmp/sums-sorted.txt`; do | |
NEWSUM=`echo "$i" | sed 's/ .*//'` | |
NEWFILE=`echo "$i" | sed 's/^[^ ]* *//'` | |
if [ "$OLDSUM" == "$NEWSUM" ]; then | |
echo ln -f "$OLDFILE" "$NEWFILE" | |
else | |
OLDSUM="$NEWSUM" | |
OLDFILE="$NEWFILE" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment