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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
# !/bin/sh
if [ $# -ne 2 ]
then
echo "Usage $0 archive.tar nom_fichier"<&2;
exit 1;
fi
if [ -d $2 ]
then
echo "$2 n'est pas un fichier accessible; Usage $0 archive.tar nom_fichier"<&2;
exit 2;
fi
Liste=0;
if [ -f $2 ]
then
a=`md5sum $2`;
b=`echo $a | cut -d " " -f1`;
for k in `tar -tf $1`
do
if [ `basename $k` = "ListeMD5Tar.txt" ]
then
Liste=1;
tar -xf $1 ListeMD5Tar.txt;
nbLigne=`wc -l essai.sh | cut -d " " -f1`;
while read ligne
do
empreinte=`echo $ligne | cut -d " " -f1`;
fichier=`echo $ligne | cut -d " " -f2`;
if [ "$b" = "$empreinte" ]
then
tar -xf $1 $fichier;
fi
done < ListeMD5Tar.txt
fi
done
fi
if [ $Liste -eq 0 ]
then
echo "Le Fichier ListeMD5Tar.txt doit être présent dans l'archive !!!";
exit 3;
fi
if [ $Liste -eq 1 ]
then
rm ListeMD5Tar.txt;
fi
exit 0; |
Partager