Blame view

rechercheDoublons.sh 1.05 KB
9f6291e4f   root   ajout
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
  #!/bin/bash
  
  function preRequis {
          for arg in $@; do
                  if ! which $arg >/dev/null; then
  			logger -t $0 La commande $arg n\'est pas installée
                          echo "La commande $arg n'est pas installée !!!"
                          echo "Fin du script."
                          exit 1
                  fi
          done
  }
  
  logger -t $0 Exécution du script
  
  PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
  
  preRequis md5sum sort awk uniq grep cut
  
  if [ ! $# -eq 1 ]; then
  	echo "Erreur !!!"
  	echo "Utilisation : $0 répertoire"
  	exit 1
  fi
  
  FILE="/tmp/filesMd5sum"
  REP="$1"
  
  if [ ! -d "$REP" ]; then
  	echo "Erreur !!!"
  	echo "$REP n'est pas un répertoire."
  	exit 1
  fi
  
  rm -f "$FILE"
1585e1dac   ronan   update find "$REP...
36
  find "$REP" -type f -exec md5sum -b {} \; > "$FILE"
9f6291e4f   root   ajout
37
38
39
40
41
42
43
44
45
46
47
48
  
  DOUBLON=0
  
  for file in $(cat "$FILE" | sort | awk '{print $1}' | uniq -d); do
  	DOUBLON=1
  	echo "Empreinte MD5 identique : $file"
  	grep $file "$FILE" | cut -d' ' -f2
  done
  
  if [ "$DOUBLON" -eq 0 ]; then echo "Aucun doublon trouvé"; fi
  
  logger -t $0 Fin d\'exécution du script
1585e1dac   ronan   update find "$REP...
49
  exit 0