58 lines
1.2 KiB
Bash
Executable File
58 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
if [ "$1" == "--help" -o "$1" == "-h" ]; then
|
|
cat <<EOF
|
|
Affiche les fichiers qui SONT des doublons, sous forme d'un script
|
|
permettant leur suppression.
|
|
Pour afficher les fichiers qui ne sont pas des doublons, utilisez
|
|
showunique.
|
|
|
|
Syntaxe : remdoubles dossier-où-chercher-les-doublons < md5sums
|
|
|
|
Exemple :
|
|
md5sums contient :
|
|
604c442629170d4bee5804b13e9a587f ./a/fichier_un
|
|
a3d0c4f97abec8c2ceaaf83020f00809 ./b/fichier_deux
|
|
a3d0c4f97abec8c2ceaaf83020f00809 ./b/fichier_trois
|
|
604c442629170d4bee5804b13e9a587f ./b/fichier_XYZ
|
|
7d4abe4e5104b71312ab56c2f341856e ./b/fichier_pas_de_doublons
|
|
Si on lance "showdoubles < md5sums", il affichera
|
|
'./a/fichier_un'
|
|
'./b/fichier_XYZ'
|
|
|
|
'./b/fichier_deux'
|
|
'./b/fichier_trois'
|
|
EOF
|
|
exit 1
|
|
fi
|
|
|
|
oldsum=""
|
|
oldnom=""
|
|
unset supprimable
|
|
first=1
|
|
q="'\\''" # escaped quote.
|
|
n=0
|
|
sort | while read ab; do
|
|
sum="${ab%% *}"
|
|
nom="${ab#* }"
|
|
if [ "$sum" != "$oldsum" ] || ! diff -q "$oldnom" "$nom" > /dev/null; then
|
|
if [ "$first" != "1" -a "$n" != 1 ]; then
|
|
echo
|
|
else
|
|
echo "$oldnom" >&2
|
|
fi
|
|
first=0
|
|
n=0
|
|
fi
|
|
if [ "$n" == 1 ]; then
|
|
echo "'${oldnom//\'/$q}'"
|
|
fi
|
|
if [ "$n" != 0 ]; then
|
|
echo "'${nom//\'/$q}'"
|
|
fi
|
|
n="$((n+1))"
|
|
|
|
oldsum="$sum"
|
|
oldnom="$nom"
|
|
done
|