Last active
February 18, 2017 02:49
-
-
Save angelworm/7fb28b623ed79950c2feda2284ae61d7 to your computer and use it in GitHub Desktop.
カレントディレクトリの重複ファイルを消すやつ
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
OIFS=$IFS | |
IFS=$'\n' | |
HASH=$(mktemp) | |
mkdir -p dup | |
for i in $(find . -maxdepth 1 -type f -not -empty -print0 | xargs -0 ls -rt); do | |
M=$(md5 -q $i); | |
if [ ! -z $(grep $M $HASH) ]; then | |
echo "DUP" $M $i; | |
mv $i dup | |
else | |
echo " " $M $i; | |
echo $M >> $HASH; | |
fi; | |
done; | |
rm $HASH | |
IFS=$OIFS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment