|
|
|
Salut,
Voila, cela est-il possible ? Oui c'est possible ;-)) Des pistes : man sed man awk man bash (commande "read") man cut Ton devoir est à rendre pour quand ? Z'@+...che. JP : Zen, my Nuggets ! ;-) $ man woman Il n'y a pas de page de manuel pour woman ! |
BIen pour les pistes....
non ce n'est pas un devoir, mais désireux d'apprendre le shell, et dans un ensemble général, à savoir ce qui est possible à faire avec. Merci. @+ |
Un truc comme ça devrait suffire :
read nombre N=$(cat $fichier | head -n1 | tr -d ' ') if [ "$nombre" = "$N" ]; then ok else pas pareil fi |
Ou encore comme ça (et il existe encore d'autres possibilités) : [jp@Mandrake tmpfs]$ cat resume.txt lsof 468 latest revision: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/ latest FAQ: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/FAQ latest man page: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/lsof_man [jp@Mandrake tmpfs]$ cat essai.sh #! /bin/bash # essai.sh echo "Entrez votre numéro identifiant : " read numero var=`sed -n '1p' resume.txt | awk ' { print $2 }'` if [ "$var" = "$numero" ] then echo "Vous avez entré le bon identifiant! " else echo "Vous n'avez pas entré le bon identifiant ! Sorry ! " fi [jp@Mandrake tmpfs]$ sh essai.sh Entrez votre numéro identifiant : 468 Vous avez entré le bon identifiant! [jp@Mandrake tmpfs]$ sh essai.sh Entrez votre numéro identifiant : 587 Vous n'avez pas entré le bon identifiant ! Sorry ! [jp@Mandrake tmpfs]$;-)) Z'@+...che. JP : Zen, my Nuggets ! ;-) Le savoir n'est bon que s'il est partagé. |
| 31/10 20h53 | Script shell : depot d'un fichier sur le net | Programmation | 31/10 22h44 | 2 |
| 14/09 17h06 | script shell exclure fichier | Linux/Unix | 14/09 18h14 | 6 |
| 25/08 00h18 | Récup de fichiers récents via script shell | Linux/Unix | 18/04 17h58 | 9 |
| 20/03 17h03 | déplacer des fichiers en script shell | Linux/Unix | 20/03 17h03 | 0 |