Probléme programmation shell

Fermé
moibibo Messages postés 2 Date d'inscription mardi 6 mars 2007 Statut Membre Dernière intervention 7 mars 2007 - 7 mars 2007 à 19:38
jipicy Messages postés 40842 Date d'inscription jeudi 28 août 2003 Statut Modérateur Dernière intervention 10 août 2020 - 7 mars 2007 à 23:22
bonjour,
je cherche comment en programmation shell batch comment mettre "ou" dans une espression? comment mettre dans une variable le résultat d'une fonction appelée?
merci par avence
A voir également:

2 réponses

jipicy Messages postés 40842 Date d'inscription jeudi 28 août 2003 Statut Modérateur Dernière intervention 10 août 2020 4 897
7 mars 2007 à 23:22
Re-

Pour le "OU" tu peux employer ce qui pourrait s'apparenter à un "OU logique", le double-pipe "||" :
#!/bin/bash

echo -e "Entrez un chiffre de 1 à 10 : \c"
read chiffre
if [ "$chiffre" = 2 ] || [ "$chiffre" = 4 ] || [ "$chiffre" = 6 ] ||\
[ "$chiffre" = 8 ] || [ "$chiffre" = 10 ]
then
echo -e "\nVous avez entrez un chiffre pair.\n"
else
echo -e "\nVous avez entrez un chiffre impair.\n"
fi

Pour ton problème de fonction :
ma_fonction ()
{
ls -l
}

var=$(ma_fonction)
echo "$var"
;-))
1
jipicy Messages postés 40842 Date d'inscription jeudi 28 août 2003 Statut Modérateur Dernière intervention 10 août 2020 4 897
7 mars 2007 à 20:16
Salut,

programmation shell batch
C'est du shell bash ou du DOS (batch) ?
0
moibibo Messages postés 2 Date d'inscription mardi 6 mars 2007 Statut Membre Dernière intervention 7 mars 2007
7 mars 2007 à 20:55
c du shell bash
0