BCCS199_Session_13 Flashcards

1
Q

The read command reads input from…?

A

stdin.

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

The test keyword allows you to make…?

A

logical tests for branching, looping, etc.

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

Conditional statements in bash are available as …?

A

if…then…[else…]fi.

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

Loops can be implemented using…?

A

for…in…do…done.

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

Command arguments in bash scripts are available as…?

A

$1, $2, $3, etc.

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

The read command reads one line of text from…?

A

stdin.

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

Format of the read command….?

A

read var1 [var2 …]

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

The test keyword can be used to test certain conditions in…?

A

bash:

test condition

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

Appears usually in the context of an…?

A

if, while, or for statement.

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

test expressions for examining file attributes:

A

-d FILE : FILE exists, and is a directory.
-e FILE : FILE exists
-f FILE : FILE exists, and is a regular file
-r FILE : FILE exists, and is readable.
-w FILE : FILE exists, and is writable.
- x FILE : FILE exists, and is executable.
FILE1 -nt FILE2 : FILE1 is newer than FILE2

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

test expressions for comparing strings…?

A

[-n] STRING : the length of STRING is greater than zero.
-z STRING : the length of STRING is zero.
STRING1 = STRING2 : STRING1 and STRING2 are equal
STRING1 != STRING2 : STRING and STRING2 are not equal.

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

logic expressions for the test Command.

A

EXPRESSION1 -a EXPRESSION 2 : Both EXPRESSION1 and EXPRESSION2 are true.
EXPRESSION1 -o EXPRESSION2 : Either EXPRESSION1 or EXPRESSION2 is true.
! EXPRESSION : EXPRESSION is false.

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

Branching in bash…?

A
If condition
then
command(s)
else
command(s)
fi
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

The for loop can be expressed like this…?

A

for VICTIM in list
do
statement(s)
done.

This will loop through every item in list, with $VICTIM representing each one in turn.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q
for loop example:
#!/bin/bash

for F in ‘ls’
do
echo “Oh, look: there’s a file called $F in $PWD!”
done

A
  • Takes the list of files in the current directory, and prints them out with a joyful comment.
  • Note the ls, and the reference to the $PWD environment variable.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

For loops are good for when loops are…?

A

bounded, i.e. you know how many times to loop.

17
Q

For unbounded loops, use..?

A

while instead:

while condition
do
statement(s)
done

18
Q

The command line can be accessed with the …?

A

$0 shell variable.

19
Q

The number of arguments included is represented by the…?

A

$# shell variable.

20
Q

Each argument is represented by…?

A

$1, $2, $3, etc.

21
Q

The shift command forces each argument to…?

A

shift down by one place. This is useful when the number of arguments can vary, or is otherwise unknown.

22
Q

The rpm command is used to..?

A

add or remove software from your system

23
Q

You must have root privileges to…?

A

add and remove software with rpm.

24
Q

Anyone can query installed packages, or…?

A

package files.

25
Q

Installed packages are maintained in the…?

A

rpm database.

26
Q

Queries can be made of the database with the…?

A

-q switch.