Skip to content

Instantly share code, notes, and snippets.

@angelworm
Last active February 18, 2017 02:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save angelworm/7fb28b623ed79950c2feda2284ae61d7 to your computer and use it in GitHub Desktop.
Save angelworm/7fb28b623ed79950c2feda2284ae61d7 to your computer and use it in GitHub Desktop.
カレントディレクトリの重複ファイルを消すやつ
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