NOS 120 MIDTERM ALL SETS QUESTIONS WITH
VERIFIED ACCURATE ANSWERS
The ____ option of the diff command ignores blanks that repeat. - Answers --b
You can use the less command with a directory to view its contents one screen at a
time, such as less /sbin. - Answers -true
One way to run a shell script is to make it executable by using the x permission and
then typing ____ prior to the script name when you run the script itself. - Answers -./
The ____ option of the diff command shows lines surrounding the line that differs. -
Answers --c
____ is a selection command. - Answers -uniq
You can use the vi editor to create script files. - Answers -true
A popular use of pr is to convert lowercase characters to uppercase characters. -
Answers -false
You use the ____ command to search for a specified pattern in a file, such as a
particular word or phrase. - Answers -grep
Bash is a freeware derivative of the Bourne and ____ shells. - Answers -Korn
The ____ command locates identical lines within two identically sorted files. - Answers -
comm
The ____ option of the grep command displays only lines that do not contain the search
pattern. - Answers --v
____ is a full-featured programming language. - Answers -Awk
compares sorted files and shows differences - Answers -comm
selects lines or rows - Answers -grep
counts characters, words, or lines in a file - Answers -wc
selects columns (fields) - Answers -cut
compares and selects differences in two files - Answers -diff
,formats and prints - Answers -pr
edits data streams - Answers -sed
sorts and merges multiple files - Answers -sort
translates and deletes character by character - Answers -tr
____ is NOT a selection command. - Answers -sed
By default, pr formats the specified files into single-column pages of ____ lines. -
Answers -66
You can use the < operator to redirect a command's output from the screen to a file. -
Answers -false, >
The ____ redirects the output of one command to the input of another command. -
Answers -pipe
The ____ function within the awk command is used to format output. - Answers -printf
The ____ command removes duplicate lines from a file. - Answers -uniq
The pipe operator can connect several commands on the same command line. -
Answers -true
Use a command to find the instances in which the word "host" is used in the /etc
directory - Answers -: Type grep host /etc/* and press Enter.
What addition to the command you used in Exercise 1 can you use to slow the output to
one screen at a time? - Answers -Add a pipe and use more or less, as in grep host
/etc/* | more or grep host /etc/* | less.
How can you determine the number of lines and words in the /etc/termcap file? -
Answers -Type wc -lw /etc/termcap and press Enter.
Use a command to remove the letters "o" and "a" from the my_list file you created in the
Hands-on Projects—and
write the output to the file changed_list. - Answers -: First, type tr -d "oa" < my_list >
changed_list and press Enter.
Use a command to find out which lines in the my_list file contain the word "Foot". -
Answers -Type grep Foot my_list and press Enter.
Create a file called trees, containing the following individual lines:
, Oak tree
Pine tree
Spruce tree
Cottonwood
Maple tree
Use the vi editor to create a file called more_trees and copy in the contents of the trees
file (if the first line is blank,
delete it). Next, add the following trees at the end of the list.
Redwood
Willow tree
Use a command to compare the trees and more_trees files and that outputs the
differences in columns. - Answers -Use the vi editor to create the trees file. Use the vi
editor with the :r option to import the trees file
into the more_trees file and then add the new lines. Type comm trees more_trees and
press Enter.
. Use a command to compare the trees and more_trees files and show the differences
in terms of individual lines that
differ. - Answers -Type diff trees more_trees and press Enter.
Determine the number of bytes in both the trees and more_trees files using a one-line
command. - Answers -Type wc -c trees more_trees and press Enter.
Use a command to replace the word "tree" with "plant" in the more_trees file and display
the output to the screen - Answers -Type sed -n s/tree/plant/p more_trees and press
Enter.
Create a new file, CD_list, and enter these lines in the file:
country:1000:210
rock:1001:380
classical:1002:52
alternative:1003:122
light rock:1004:151
light rock:1004:151
celtic:1005:44
jazz:1006:62
soundtracks:1007:32
soundtracks:1007:32
Use the sed command and a script file to add these lines to the end of the CD_list file:
hard rock:1008:70
misc:1009:22 - Answers -After you create the file CD_list and the script file (see file
CD_more file information below) type
sed -f CD_more CD_list | cat > CD_list and press Enter.
To create the CD_more file enter vi CD_more and type in the following lines:
$a\
hard rock:1008:70\
VERIFIED ACCURATE ANSWERS
The ____ option of the diff command ignores blanks that repeat. - Answers --b
You can use the less command with a directory to view its contents one screen at a
time, such as less /sbin. - Answers -true
One way to run a shell script is to make it executable by using the x permission and
then typing ____ prior to the script name when you run the script itself. - Answers -./
The ____ option of the diff command shows lines surrounding the line that differs. -
Answers --c
____ is a selection command. - Answers -uniq
You can use the vi editor to create script files. - Answers -true
A popular use of pr is to convert lowercase characters to uppercase characters. -
Answers -false
You use the ____ command to search for a specified pattern in a file, such as a
particular word or phrase. - Answers -grep
Bash is a freeware derivative of the Bourne and ____ shells. - Answers -Korn
The ____ command locates identical lines within two identically sorted files. - Answers -
comm
The ____ option of the grep command displays only lines that do not contain the search
pattern. - Answers --v
____ is a full-featured programming language. - Answers -Awk
compares sorted files and shows differences - Answers -comm
selects lines or rows - Answers -grep
counts characters, words, or lines in a file - Answers -wc
selects columns (fields) - Answers -cut
compares and selects differences in two files - Answers -diff
,formats and prints - Answers -pr
edits data streams - Answers -sed
sorts and merges multiple files - Answers -sort
translates and deletes character by character - Answers -tr
____ is NOT a selection command. - Answers -sed
By default, pr formats the specified files into single-column pages of ____ lines. -
Answers -66
You can use the < operator to redirect a command's output from the screen to a file. -
Answers -false, >
The ____ redirects the output of one command to the input of another command. -
Answers -pipe
The ____ function within the awk command is used to format output. - Answers -printf
The ____ command removes duplicate lines from a file. - Answers -uniq
The pipe operator can connect several commands on the same command line. -
Answers -true
Use a command to find the instances in which the word "host" is used in the /etc
directory - Answers -: Type grep host /etc/* and press Enter.
What addition to the command you used in Exercise 1 can you use to slow the output to
one screen at a time? - Answers -Add a pipe and use more or less, as in grep host
/etc/* | more or grep host /etc/* | less.
How can you determine the number of lines and words in the /etc/termcap file? -
Answers -Type wc -lw /etc/termcap and press Enter.
Use a command to remove the letters "o" and "a" from the my_list file you created in the
Hands-on Projects—and
write the output to the file changed_list. - Answers -: First, type tr -d "oa" < my_list >
changed_list and press Enter.
Use a command to find out which lines in the my_list file contain the word "Foot". -
Answers -Type grep Foot my_list and press Enter.
Create a file called trees, containing the following individual lines:
, Oak tree
Pine tree
Spruce tree
Cottonwood
Maple tree
Use the vi editor to create a file called more_trees and copy in the contents of the trees
file (if the first line is blank,
delete it). Next, add the following trees at the end of the list.
Redwood
Willow tree
Use a command to compare the trees and more_trees files and that outputs the
differences in columns. - Answers -Use the vi editor to create the trees file. Use the vi
editor with the :r option to import the trees file
into the more_trees file and then add the new lines. Type comm trees more_trees and
press Enter.
. Use a command to compare the trees and more_trees files and show the differences
in terms of individual lines that
differ. - Answers -Type diff trees more_trees and press Enter.
Determine the number of bytes in both the trees and more_trees files using a one-line
command. - Answers -Type wc -c trees more_trees and press Enter.
Use a command to replace the word "tree" with "plant" in the more_trees file and display
the output to the screen - Answers -Type sed -n s/tree/plant/p more_trees and press
Enter.
Create a new file, CD_list, and enter these lines in the file:
country:1000:210
rock:1001:380
classical:1002:52
alternative:1003:122
light rock:1004:151
light rock:1004:151
celtic:1005:44
jazz:1006:62
soundtracks:1007:32
soundtracks:1007:32
Use the sed command and a script file to add these lines to the end of the CD_list file:
hard rock:1008:70
misc:1009:22 - Answers -After you create the file CD_list and the script file (see file
CD_more file information below) type
sed -f CD_more CD_list | cat > CD_list and press Enter.
To create the CD_more file enter vi CD_more and type in the following lines:
$a\
hard rock:1008:70\