Class 22 Flashcards
What are control structures?
syntactic structures that control how and when other statements are executed
What are the two basic types of control structures?
conditionals and loops
What is the basic format of the if … then construct?
if COMMAND
then
COMMAND_1
COMMAND_2
…
fi
How is the command that follows if used to determine whether or not the statements between the then and fi keywords are executed?
if the command returns an exit status of 0 the statements are executed
What does an exit status of 0 mean?
that the command that returned the status code ran without error
What are the two keywords that surround the statements inside an if statement?
then and fi
Can the then keyword appear on the same line as if ?
yes, but only if it is separated from it by a semicolon (;)
What does the test command do?
analyze a logical expression and return an exit status that tells whether the expression is true or false
What is the value of the exit status returned by test to indicate that the expression is true?
0
Does the command that follows if need to be test?
no, it can be any command that returns an exit status