From 734b3ee3f3dc510742d641b6ff05aed7864c69e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georges=20Dup=C3=A9ron?= Date: Fri, 24 Sep 2010 22:48:48 +0200 Subject: [PATCH] =?UTF-8?q?D=C3=A9tection=20de=20fichier=20dans=20un=20cer?= =?UTF-8?q?tain=20sous-dossier=20ayant=20des=20doublons=20ailleurs.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- remdoubles | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 remdoubles diff --git a/remdoubles b/remdoubles new file mode 100755 index 0000000..9e6dc54 --- /dev/null +++ b/remdoubles @@ -0,0 +1,33 @@ +#!/bin/bash + +oldsum="" +unset supprimable +n=0 +orig="" +q="'\\''" # escaped quote. +while read ab; do + sum="${ab%% *}" + nom="${ab#* }" + if [ "$sum" != "$oldsum" ]; then + if [ -n "$orig" ]; then + for i in "${supprimable[@]}"; do + if diff -q "$orig" "$i"; then + echo "rm '${i//\'/$q}'" + fi + done + fi + + unset supprimable + orig="" + n=0 + fi + + if [ "${nom#$1}" != "$nom" ]; then + supprimable[n]="$nom" + n=$(($n+1)) + else + orig="$nom" + fi + + oldsum="$sum" +done