How To Use Conditions In Shell Scripts
Apr 02, 2010, 01:34 (2 Talkback[s])
[ Thanks to Andrew
Weber for this link. ]
"Conditions are elements that you will use often. With
conditions you will test for an element and then create a response
to the results of that test. In most situations, conditions will be
a very important part of your scripts.
"In the example below, the if starts the condition and then
inside the brackets, which equates to the test command, is the
element that is tested, is the number 15 equal to (-eq) the number
15, of course it is true and will exit with a “0” to
indicate it is true. So the then will evaluate the zero and echo
the Success line. If it exited with any number besides
“0”, it would indicate that it failed so the second
Failure line would echo."