From 33de113af57757d98950dfa0590804a98970c53d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georges=20Dup=C3=A9ron?= Date: Wed, 13 Oct 2010 18:32:11 +0200 Subject: [PATCH] Nouveaux scripts + corrections dans les anciens. --- quickhash | 13 ++++++++++++ remdoubles | 2 +- showdoubles | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++ showunique | 2 +- 4 files changed, 72 insertions(+), 2 deletions(-) create mode 100755 quickhash create mode 100755 showdoubles diff --git a/quickhash b/quickhash new file mode 100755 index 0000000..cf1556c --- /dev/null +++ b/quickhash @@ -0,0 +1,13 @@ +#!/bin/sh + +find "$@" -type f -printf "%s %p\n" | while read ab; do + sum="$(printf %8.8x "${ab%% *}")" + nom="${ab#* }" + mdsum="$(dd if="$nom" bs=512 count=1 2>/dev/null | md5sum 2>/dev/null)" + mdsum="${mdsum%% *}" + sum="$sum$mdsum" + if [ "${#sum}" != "40" ]; then + sum="0000000000000000000000000000000000000000" + fi + echo "$sum $nom" +done diff --git a/remdoubles b/remdoubles index a3186e4..052daf4 100755 --- a/remdoubles +++ b/remdoubles @@ -48,7 +48,7 @@ sort | while read ab; do if [ "$sum" != "$oldsum" ]; then if [ -n "$orig" ]; then for i in "${supprimable[@]}"; do - if diff -q "$orig" "$i"; then + if diff -q "$orig" "$i" > /dev/null; then echo "rm '${i//\'/$q}'" fi done diff --git a/showdoubles b/showdoubles new file mode 100755 index 0000000..744c06b --- /dev/null +++ b/showdoubles @@ -0,0 +1,57 @@ +#!/bin/bash + +if [ "$1" == "--help" -o "$1" == "-h" ]; then + cat < /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 diff --git a/showunique b/showunique index 80847ba..9a20834 100755 --- a/showunique +++ b/showunique @@ -35,7 +35,7 @@ sort | while read ab; do if [ "$sum" != "$oldsum" ]; then if [ -n "$orig" ]; then for i in "${supprimable[@]}"; do - if diff -q "$orig" "$i"; then + if diff -q "$orig" "$i" > /dev/null; then : else # Pas de clone à l'extérieur, on affiche.