13.8.1 Exercice Le script : #!/bin/bash echo Nom du script : $0 echo Je suis appelé avec $# arguments echo qui sont $* son execution : thebault@listrac:~$ chmod u+x test.sh thebault@listrac:~$ ./test.sh Nom du script : ./test.sh Je suis appelé avec 0 arguments qui sont thebault@listrac:~$ ./test.sh bienvenue dans le monde Unix Nom du script : ./test.sh Je suis appelé avec 5 arguments qui sont bienvenue dans le monde Unix 13.8.2 Exercice: Scripts : Vador.sh : variable=test1 echo 1. $variable export variable sh luke.sh echo 2. $variable Luke.sh : echo l1. $variable variable=test2 echo l2 $variable Lancement des scripts : thebault@listrac:~/tp3$ ./vador.sh 1. test1 l1. test1 l2 test2 2. test1 13.8.3 Exercice: Dans le script, on retrouve les lignes suivantes : cpt=1 for i in *;do echo $cpt")" $i cpt=$((cpt+1)) done Execution : thebault@listrac:~/tp3$ sh c_test.sh 1) Bienvenue.sh 2) c_test.sh 3) c_test.sh~ 4) luke.sh 5) luke.sh~ 6) test1.sh 7) test1.sh~ 8) vador.sh 9) vador.sh~ 13.8.4 Exercice : Dans le script, on retrouve : cpt=1 affiche=Bonjour while [ $cpt -le 5 ];do echo $cpt")" $1 sleep 1 cpt=$((cpt+1)) done A l'excécution, on aura : thebault@listrac:~/tp3$ sh exemple1.sh test 1) test 2) test 3) test 4) test 5) test Pour excécution le script 3 fois et en même temps, on fait : thebault@listrac:~/tp3$ sh ex.sh toto & sh ex.sh tata & sh ex.sh tutu [1] 10606 [2] 10607 1) toto 1) tata 1) tutu 2) toto 2) tata 2) tutu 3) toto 3) tata 3) tutu 4) toto 4) tata 4) tutu 5) toto 5) tata 5) tutu [1]- Done sh ex.sh toto 13.8.5 Exercice : Le script : rep=$1; cd $rep; for i in * do echo $i if [ -d $i ];then echo "\n";temp=$rep$i; sh ~/recurls $i;echo "\n\n"; fi done 13.8.6 Exercice : for i in *$1 do echo $1 nom=`basename $i $1` mv $nom$1 $nom$2 echo "fichier renommé en : "$nom$2 done 13.8.7 Exercice On faut regarder si $1 est définie, et si oui, alors rien ne ce passe En revanche si $l ne l'est pas, il recois la valeur $i et retourne la retourne. 13.8.8 : Afficher la liste : ps -o pid -C listrac ps -o pid -C update-notifier Il faut retirer le pid de cette colone pour mieux l'expoité