Revision [538]

This is an old revision of HowToConditional made by DavidLee on 2009-05-21 18:53:46.

 

How To test a condition


Conditions can be tested with either the boolean operations "
" and "&&" or with the the if/elif/else/then clauses.

Boolean Operations


If you only need execute a single command or a small block then boolean operations are the easiest way

for example

if "command" returns successfully then print "is success"

$ command && echo is success


If the file "myfile.txt" exists then read the first line from the file and print it.

$ [ -e myfile.txt ] && { read VAR < myfile.txt ;  echo $VAR ; }






There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki