The test Command

The test command can be used to check a condition and determine if it is true or false.  The value “true” is zero(0).  The value “false” is often one(1), but may be another non-zero value.   There are three main sets of operators that can be used:

The equal sign (=) can be used as an operator to test if two strings are the same.  Leave blanks on both sides of the equal sign.  If you don't leave blanks, you will either get an error or you will be setting the variable. It is case sensitive, so “abc” does not equal “abC”.

For example:

Another example:

This can also be used to compare variables.

The [ ] Command

The [ ] command can be used in place of the test command.  Leave blanks on both sides of each bracket ( [ and ] ).  For example: