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 66
The back quote marks (") perform a different function. They are used when you want to use the
results of a command in another command. For example, if you wanted to set the value of the
variable contents equal to the list of files in the current directory, you would type the following
command:
5.8 The test Command
A command called test is used to evaluate conditional expressions. You would typically use
the test command to evaluate a condition that is used in a conditional statement, or to evaluate
the entry or exit criteria for an iteration statement. The test command has the following syntax:
5.8.1 Integer operators
Variable Symbol Description
int1 -eq int2
Returns True if int1 is equal to int2.
int1 -ge int2
Returns True if int1 is greater than or equal to int2.
int1 -gt int2
Returns True if int1 is greater than int2.
int1 -le int2
Returns True if int1 is less than or equal to int2.
int1 -lt int2
Returns True if int1 is less than int2.
5.8.2 String operators
Variable Symbol Description
str1 = str2
Returns True if str1 is identical to str2.
str1 != str2
Returns True if str1 is not identical to str2.
str
Returns True if str1 is not null.
-n str
Returns True if the length of str is greater than zero.
-z str
Returns True if the length of str is equal to zero.
contents='ls'
ยด
test expression
or
[ expression ]
Several built-in operators can be used with the test command. These operators can be classified
in four groups: integer operators, string operators, file operators, and logical operators.