Class 22 Flashcards

1
Q

What are control structures?

A

syntactic structures that control how and when other statements are executed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the two basic types of control structures?

A

conditionals and loops

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the basic format of the if … then construct?

A

if COMMAND
then
COMMAND_1
COMMAND_2

fi

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How is the command that follows if used to determine whether or not the statements between the then and fi keywords are executed?

A

if the command returns an exit status of 0 the statements are executed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does an exit status of 0 mean?

A

that the command that returned the status code ran without error

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are the two keywords that surround the statements inside an if statement?

A

then and fi

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Can the then keyword appear on the same line as if ?

A

yes, but only if it is separated from it by a semicolon (;)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What does the test command do?

A

analyze a logical expression and return an exit status that tells whether the expression is true or false

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the value of the exit status returned by test to indicate that the expression is true?

A

0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Does the command that follows if need to be test?

A

no, it can be any command that returns an exit status

How well did you know this?
1
Not at all
2
3
4
5
Perfectly