‼
To give you the best experience, this site uses cookies. Continuing to use
9bis.net
means you agree to our use of cookies.
If_Then_Else_Fi
(
fr )
Dernière modification : 2013/01/26 19:17
Index
/
Changements récents
/
Informations
/
Forum
/
Télécharger
/
Contact
Éditer (
Aide
) /
Renommer
/
Historique
The main conditional block structure is the '''if ... then ...fi''' block. The two syntaxes are{if {[} ''expr'' {]} then ''command'' fi}and with an '''else''' expression{if {[} ''expr'' {]} then ''command 1'' else ''command 2'' fi} Never forget spaces characters before and after '''{[}''' and '''{]}'''. '---example---' {msh> set A=100 msh> if {[} $A -gt 0 {]} ; then 1> echo "A is a positive number" 1> else 1> echo "A is a negative or null number" 1> fi A is a positive number} To get information about test expressions see [test] command. Without '''else''' expression the syntax can be shorten as follow '''{[}{[} ... {]}{]} {{} ... {}}'''. {msh> ^[^[ -f filename ^]^] print Filename exists Filename exists}
Mot de passe :
Wiki utilisant
PumaWiki 1.0
2025/05/09 10:53 -- fr -- 18.119.0.35