NOS 120 STUDY CHAPTER 7 EXAM
QUESTION AND ANSWERS
When writing shell scripts and using an if statement to determine
whether a set of code should be executed, what is the proper syntax to
end the if construct? Answer: ________________________________ -
ANSWER fi
The subdirectory newdir does not currently exist in the current directory
that you are in. Which of the following commands will create a new
directory named newdir and then change into that directory? (Choose
two.)
Select one or more:
a. mkdir newdir; cd newdir
b. mkdir newdir || cd newdir
c. mkdir newdir >> cd newdir
d. mkdir newdir && cd newdir - ANSWER mkdir newdir && cd newdir
mkdir newdir; cd newdir
How many times will the following loop execute as part of a script:
#!/bin/bash
COUNTER=0
while [ $COUNTER -lt 7 ]
do
echo "hello world"
done
Select one:
a. 7
b. 0
c. 1
d. until ctrl-c is used to terminate it - ANSWER until ctrl-c is used to
terminate it
Which of the following will the split command do on a file when no other
options are specified?
, Select one:
a. It will split a file into new files that are 1 kilobyte each.
b. It will split a file into new equally sized files that are 1/10th of the
original file size.
c. It will split a file into new files that are 1 megabyte each.
d. It will split a file into new files that are 1,000 lines each. - ANSWER It
will split a file into new equally sized files that are 1/10th of the original
file size.
Match the file with the order in which the BASH shell environment files
are read:
/etc/profile, /etc/bashrc, ~/.bashrc, /etc/profile.d/* - ANSWER Second
/etc/profile.d/*
Fourth
~/.bashrc
Third
/etc/bashrc
First
/etc/profile
Which of the following is a valid method of running a script named
myscript.sh? (Choose two)
Select one or more:
a. source myscript.sh
b. run myscript.sh
c. ./myscript.sh
d. exec ./myscript.sh - ANSWER ./myscript.sh
source myscript.sh
Which of the following would be the results of running the command seq
7?
Select one:
a. 6 through 0 being displayed one number per line.
b. 7 through 1 being displayed one number per line.
c. 0 through 6 being displayed one number per line.
d. 1 through 7 being displayed one number per line. - ANSWER 1
through 7 being displayed one number per line.
QUESTION AND ANSWERS
When writing shell scripts and using an if statement to determine
whether a set of code should be executed, what is the proper syntax to
end the if construct? Answer: ________________________________ -
ANSWER fi
The subdirectory newdir does not currently exist in the current directory
that you are in. Which of the following commands will create a new
directory named newdir and then change into that directory? (Choose
two.)
Select one or more:
a. mkdir newdir; cd newdir
b. mkdir newdir || cd newdir
c. mkdir newdir >> cd newdir
d. mkdir newdir && cd newdir - ANSWER mkdir newdir && cd newdir
mkdir newdir; cd newdir
How many times will the following loop execute as part of a script:
#!/bin/bash
COUNTER=0
while [ $COUNTER -lt 7 ]
do
echo "hello world"
done
Select one:
a. 7
b. 0
c. 1
d. until ctrl-c is used to terminate it - ANSWER until ctrl-c is used to
terminate it
Which of the following will the split command do on a file when no other
options are specified?
, Select one:
a. It will split a file into new files that are 1 kilobyte each.
b. It will split a file into new equally sized files that are 1/10th of the
original file size.
c. It will split a file into new files that are 1 megabyte each.
d. It will split a file into new files that are 1,000 lines each. - ANSWER It
will split a file into new equally sized files that are 1/10th of the original
file size.
Match the file with the order in which the BASH shell environment files
are read:
/etc/profile, /etc/bashrc, ~/.bashrc, /etc/profile.d/* - ANSWER Second
/etc/profile.d/*
Fourth
~/.bashrc
Third
/etc/bashrc
First
/etc/profile
Which of the following is a valid method of running a script named
myscript.sh? (Choose two)
Select one or more:
a. source myscript.sh
b. run myscript.sh
c. ./myscript.sh
d. exec ./myscript.sh - ANSWER ./myscript.sh
source myscript.sh
Which of the following would be the results of running the command seq
7?
Select one:
a. 6 through 0 being displayed one number per line.
b. 7 through 1 being displayed one number per line.
c. 0 through 6 being displayed one number per line.
d. 1 through 7 being displayed one number per line. - ANSWER 1
through 7 being displayed one number per line.