February 2001
Beginner to intermediate
448 pages
9h 2m
English
To find out the truth, you must ask questions. The if test provides a means for the script to query a variable, compare strings, check a loop counter, find out whether a command completed successfully, and perform similar activities.
Basic if-test syntax is as follows:
if command then command(s) fi
Cute, huh? The logic of the if test is bracketed by the words if and fi, which is “if” spelled backwards. You will see this same cuteness one other time in this chapter (case/esac). The syntax means that if the command is true, then do the command or commands appearing between the then and the fi. But how does a command become true or false?
As a command completes, it reports its exit status to the shell. This status is held in a special ...
Read now
Unlock full access