Class 23 Quiz Flashcards

1
Q

What do [ and ] mean when used in an if statement?

A

they stand for the test command

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

What are the keywords used to mark a block of commands in an if … then statement?

A

then and fi

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

What are the keywords used to mark the first block of commands in an if … then … else statement?

A

then and else

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

What are the keywords used to mark the second block of commands in an if … then … else statement?

A

else and fi

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

What are the keywords used to mark the block of commands following elif?

A

then and either else or elif or fi

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

Is there any limit to the number of blocks of commands you can have in an if … else … elif statement?

A

no

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

How would you run the script do_something.sh if you wanted to print each line of the script before it was executed?

A

bash -x do_something.sh

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

If you were debugging a script as in the example above, how would Bash mark the lines of the script itself to distinguish them from the output of the script?

A

by starting each line with a +

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

What has to follow each elif in an if … else … elif statement?

A

a Unix command

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

How does the test command indicate that the logical expression it is evaluating is true?

A

by returning a status code of 0

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