Exercice Unix corrigé script Shell – backup – poubelle – commande – trash – find

Exercice 1:

#!/bin/bash
FILES=`find ~ -name '*~' -type f | grep -v Backup`
mv -vi $FILES ~/Backup

Exercice 2:

#!/bin/bash
if [ -z $1 ] 
then
cat <<EOF 
Usage : trash [-h|-e|-c] [fichier1 ... fichiern]
EOF
exit 0
fi
if [ $1 = '-h' ]
then
cat <<EOF
Usage : trash [-h|-e|-c] [fichier1 ... fichiern]
EO
exit 0
fi
if [ $1 = '-c' ]
then
du -sk ~/Poubelle
exit 0
fi
if [ $1 = '-e' ]
then
rm -rf ~/Poubelle/*
exit 0
fi
for I in $*
do
mv $I ~/Poubelle
done

Télécharger aussi :

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *