‼
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
(
en )
Last modification : 2013/01/26 19:16
Index
/
Recent changes
/
News
/
Forum
/
Download
/
Contact
Edit (
Help
) /
Rename
/
History
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}
Password :
Wiki utilisant
PumaWiki 1.0
2024/05/16 21:04 -- en -- 3.141.47.163