Linux 2 Ch 2-Shell scripts Flashcards

(16 cards)

1
Q

exec

A

Replaces the current process with a specified command. If no command is specified, the exec command spawns a new shell process and returns a shell prompt.

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

if

A

if <condition1> is met, do <commands1>; otherwise, if condition2 is met, do <commands2>; if neither is met, do <commands3>.</commands3></commands2></commands1></condition1>

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

read

A

Reads one line of standard input and assigns each word to the corresponding variable, with all leftowver words assigned to the last variable.

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

seq

A

Prints a sequence of numbers from FIRST to LAST, in steps of INCREMENT. Generally used in shell scripts.

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

test

A

Used with conditional constructs in shell scripts; test evaluates a condition and, if its value is true, returns a zero exit status; otherwise, returns a nonzero exit status.

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

while

A

while <condition> is met, do <commands>. <Condition> is usually specified with the test command.</Condition></commands></condition>

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

The bash script_file command can be used to directly execute a shell script.
True or False?
True
False

A

True

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

Which of the following is placed before a script name to execute it from the current directory?
!!
//
./
#!

A

./

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

What will the following command do (select all that apply):
read -p “Enter data> “ test
(choose two)
Work the same way as the type command
Print the input on local printer
Show a prompt along with blinking cursor
Store user input into a variable called test

A

Show a prompt along with blinking cursor
Store user input into a variable called test

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

The return status from a command is 1. What does this indicate?
Command executed successfully
Command did not execute successfully
Command is still running in the background
Calculation done by the command yields the result 1

A

Command did not execute successfully

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

The joanne user wants an email sent when her shell script is executed successfully. Which of the following commands in the script can do this?
cron job will send an email by default
echo $mail
mail root
mail joanne

A

mail joanne

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

What will the following statement do?
for name in cat /root/users

Run for two values; cat and /root/users
Get into an infinite loop
Assign to the name variable each value in the specified file
Report an error

A

Assign to the name variable each value in the specified file

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

The output of the command seq 10 10 30 will be:
10 20 30
10 10 30
3
50

A

10 20 30

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

The ___________ command is used to print a sequence of numbers.
series
list
seq
num

A

seq

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

The statement if [ -d file ] will be true, if the file:
Is executable
Exists
Is a directory
Is writable

A

Is a directory

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

Command substitution CAN NOT be used to insert the output of a command as another command’s argument.
False
True