System information
An Introduction to Shells in General
Axis Communications AB provides NO support for application development of any kind. The information
here is provided "as is", and there is no guarantee that any of the examples shown will work in your
particular application.
Revision 1.02 October 2002 67
5.8.3 File operators
Variable Symbol Description
-d filename
Returns True if filename is a directory.
-f filename
Returns True if filename is an ordinary file.
-r filename
Returns True if the process can read filename.
-s filename
Returns True if filename has a non-zero length.
-z filename
Returns True if the process can write filename.
-x filename
Returns True if filename is executable.
-e filename
Returns True if filename exists.
5.8.4 Logical operators
Variable Symbol Description
! expr
Returns True if expr is not true.
expr1 –a
expr2
expr1 &&
expr2
Returns True if expr1 and expr2 are true.
expr1 –o
expr2
expr1 ||
expr2
Returns True if expr1 or expr2 is true.
5.8.5 Conditional statements
The if statement
The syntax of the if statement is:
if [ expression ];
then
commands
elif [ expression2 ];
then
commands
else
commands
fi
The elif and else clauses are both optional parts of the if statement. The elif statement is
an abbreviation of else if. This statement is executed only if none of the expressions
associated with the if statement or any elif statements before it were true. The commands
associated with the else statement are executed only if none of the expressions associated with
the
if statement or any of the elif statements were true.