[Shell] imbrication if ... else
Résolu
tonio4531
-
tonio4531 -
tonio4531 -
Bonjour à tous,
Je suis face à une autre, en fait je désire réaliser des tests genre if ... else if en ksh
Voici mon code :
[code]
if [ $COM = 'ALL' ]
if [ $EXP = 'A']
then
echo "ALL A"
elif [ $EXP = 'I' ]
then
echo "ALL I"
else
echo "ALL E"
fi
elif [ $COM = 'K' ]
if [ $EXP = 'A' ]
then
echo "K A"
elif [ $EXP = 'I' ]
then
echo "K I"
else
echo "K E"
fi
fi
[/code]
En gros dans l'esprit c'est ça.
Mais il bloque sur le elif [ $COM = 'K' ]
Savez-vous pourquoi ? y'a -t-il une limite dans le nombre d'imbrication qu'il est possible de faire sous ksh.
Merci par avance pour vos réponses.
Cdlt,
Je suis face à une autre, en fait je désire réaliser des tests genre if ... else if en ksh
Voici mon code :
[code]
if [ $COM = 'ALL' ]
if [ $EXP = 'A']
then
echo "ALL A"
elif [ $EXP = 'I' ]
then
echo "ALL I"
else
echo "ALL E"
fi
elif [ $COM = 'K' ]
if [ $EXP = 'A' ]
then
echo "K A"
elif [ $EXP = 'I' ]
then
echo "K I"
else
echo "K E"
fi
fi
[/code]
En gros dans l'esprit c'est ça.
Mais il bloque sur le elif [ $COM = 'K' ]
Savez-vous pourquoi ? y'a -t-il une limite dans le nombre d'imbrication qu'il est possible de faire sous ksh.
Merci par avance pour vos réponses.
Cdlt,
A voir également:
- Shell if else
- Classic shell - Télécharger - Personnalisation
- Ssh secure shell download - Télécharger - Divers Web & Internet
- If exist ✓ - Forum Autoit / batch
- Shell startup windows 10 - Guide
- The realtek network controller was not found. if deep sleep mode is enabled please plug the cable ✓ - Forum Pilotes (drivers)
1 réponse
Salut,
je n'ai pas testé ton code, mais à la première vue il manque un then (voir en gras)
si tu indentes ton code tu gagneras en visibilité ;-)
je n'ai pas testé ton code, mais à la première vue il manque un then (voir en gras)
si tu indentes ton code tu gagneras en visibilité ;-)
if [ $COM = 'ALL' ] then if [ $EXP = 'A'] then echo "ALL A" elif [ $EXP = 'I' ] then echo "ALL I" else echo "ALL E" fi elif [ $COM = 'K' ] if [ $EXP = 'A' ] then echo "K A" elif [ $EXP = 'I' ] then echo "K I" else echo "K E" fi fi
tonio4531
oki je te remercie ça marche impec maintenant !