Networking Chapter 5 Homework You have just finished a 25-page paper that you have written using

subject Type Homework Help
subject Pages 8
subject Words 2802
subject Authors Michael Palmer

Unlock document.

This document is partially blurred.
Unlock all pages and 1 million more documents.
Get Access
page-pf1
1
Guide to UNIX Using Linux Fourth Edition
Chapter 5 Solutions
Answers to the Chapter 5 Review Questions
1. You have just finished a 25-page paper that you have written using Emacs. The file containing the
paper is called /assignments/data_sources. After your instructor has briefly looked at the paper,
she recommends that you change all instances of the reference “data is” to “data are” before you
submit it. Which of the following commands can you use to locate these references in the file for a
quick assessment of how much you have to change?
2. You are interested in determining the number of words in your /assignments/data_sources file
mentioned in Question 1. Which of the following commands should you use?
3. Which of the following are examples of manipulation and transformation commands? (Choose all
that apply.)
4. Which of the following is true of the pipe operator? (Choose all that apply.)
5. Because the data was formatted the same in two inventory files, you decided to combine their
contents into one file. Now you want to determine if there are duplicate entries on consecutive
lines in the new file. Which of the following commands enables you to find the duplicate entries?
6. Your friend is using the command comm entryfile, but is getting an error message. What is the
problem? (Choose all that apply.)
7. Your boss is trying to import the customers file into her spreadsheet program, but the data goes
into the spreadsheet incorrectly. This is because the fields are separated by dashes (-) and the
spreadsheet program requires the fields to be separated by colons (:). Which of the following
commands can you use to convert the customers file?
8. How can you link multiple files to manipulate the data in those files?
9. While in the Bash shell, you have written a simple script file and now want to execute the script.
Which of the following commands enables you to run the script?
10. You are using the grep command, but it is only searching through files in your immediate home
directory. What option enables you to search through subdirectories below your home directory?
11. Your software has a bug in that it enables you to create a vendors file in which there are duplicate
entries of vendors. Which of the following methods enables you to remove the duplicate vendors
in this text file?
page-pf2
12. Each time you list the files in your home directory, the output scrolls by so fast you can’t read it.
Which of the following enables you to view the output one screen at a time?
13. You are creating a file to send over the Internet via a satellite connection that only allows you to
send files under 250 KB. Which of the following commands enables you to determine the number
of bytes in the file before you try to send it?
14. In the command sed -f fixit notes > instructions, what is “fixit”?
15. When you design a record layout, you should do which of the following?(Choose all that apply.)
16. What sed command option enables you to append new text to a file?
17. Your boss has two salary scale files, salary and salary1, and wants to compare their contents side
by side to see if there are any differences in the files. Which of the following commands should he
use? Answer: b. comm salary salary1
18. When you use the pr command how can you limit the output to only a screen full of text to view.
(Choose all that apply.)
19. When you use the Awk printf capability, what does the dollar sign ($) represent?
20. Your boss is trying to delete the word “difficult” as it appears in a text file containing his speech
about motivation. The name of the file is motivate. When he decides to use the tr command to
delete this word, it instead deletes characters throughout the text. Which of the following
commands is he likely to have used?
21. When you enter the command grep Linux /info/Linux_features | head, what is the maximum
number of lines that will be displayed?
22. List four examples of selection commands.
23. What is the general format for using the pipe operator?
24. Briefly explain what you can accomplish with the sed command.
page-pf3
3
25. You want to create a file of your friends and relatives names, addresses, telephone numbers, and
other information. When you mention this to your sister-in-law, she recommends having separate
fields for the first, middle, and last names. Briefly explain why this is a good idea.
Hands-On Projects Tips and Solutions for Chapter 5
Project 5-1
Students learn to use the pipe command in this project. Consider having them try the command on
other directories, such as /sbin or their home directories.
Project 5-2
This project enables students learn how to combine commands on a single line using the pipe
command.
Project 5-3
In this project, students go through several sets of steps to learn grep. Note that while Fedora, Red Hat
Enterprise Linux, and SUSE have the /etc/termcap file used in this project, Knoppix does not. Consider
In the first set of steps, students search for IBM and learn how to pipe results into more and head.
In the second set of steps, students practice ignoring case, using a metacharacter for a search, and using
a wildcard. Also, in Step 7 of this series of steps, a sampling of the /etc files containing linux or Linux
includes:
/etc/aliases.db
/etc/at.deny
/etc/autofs_ldap_auth.conf
/etc/auto.misc
/etc/cron.d
/etc/DIR_COLORS
page-pf4
4
/etc/services
/etc/sestatus.conf
/etc/shadow
In the third set of steps, students learn how to search for a specific string by using quotes around the
string. This is useful for searching phrases that contain spaces, for example.
In the fourth set of steps, students pipe the output of ls into grep.
Project 5-4
.
For this project, students use the uniq command to remove duplicate lines in one file and output the
result to another file.
Project 5-5
In this project, students use the comm command to compare the contents of two files.
Project 5-6
In this project, students use the diff command to compare the contents of the zoo1 and zoo2 files.
Project 5-7
For this project, students practice using the options associated with the wc command to determine byte,
line, and word count for a file.
Project 5-8
Students use sed to modify the output of a file’s contents in this project. The focus of this project is
using sed from the command line.
Project 5-9
In this project, students use the script method to modify the output of a file’s contentss via the sed
command.
Project 5-10
For this project, students use the tr command to change capitalization in a file and then to delete and
replace characters in files.
Project 5-11
This project enables students to use the pr command to format the unix_stuff file first using the pipe
operator and then comparing its results to using the -l option for pr.
Project 5-12
page-pf5
5
Project 5-13
For this project, students use the awk command to create a simple report from the programmer file.
Project 5-14
This project enables students to compare the work in creating the same report, using multiple cut and
paste commandscompared to using one awk command.
Project 5-15
Project 5-17
For this project, students use the sh command to run the pact script they created in Hands-on Project 5-
16.
Project 5-18
In the project, students create a script file, pnumname, to extract the programmer names and numbers
from the programmer file, and redirect the output to the file pnn. This is another step along the way to
complete the final project to generate the Programmer Activity Status Report.
Project 5-19
Discovery Exercises
1. Use a command to find the instances in which the word “host” is used in the /etc directory.
page-pf6
6
2. What addition to the command you used in Exercise 1 can you use to slow the output to one
screen at a time?
3. How can you determine the number of lines and words in the /etc/termcap file?
4. Use a command to remove the letters “o” and “a” from the my_list file you created in the Hands-
on Projectsand write the output to the file changed_list.
5. Use a command to find out which lines in the my_list file contain the word “Foot”.
6. 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.
7. Use a command to compare the trees and more_trees files and show the differences in terms of
individual lines that differ.
8. Determine the number of bytes in both the trees and more_trees files using a one-line command.
9. Use a command to replace the word “tree” with “plant” in the more_trees file and display the
output to the screen.
Answer: Type sed -n s/tree/plant/p more_trees and press Enter.
page-pf7
7
10. 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
11. Use a command to find the duplicate lines (records) in the CD_list file.
12. Use the uniq command to remove the duplicate lines in the CD_list file, placing the corrected
information in a file called CD_list_new.
13. In the CD_list_new file, replace the word “misc” with “other,” save the changes in the file
CD_list_replace, and then compare the contents of the CD_list file with the CD_list_replace file to
ensure your changes are implemented
14. Use the grep command to find all the lines that contain the word “celtic” in the CD_list_new file
Answer: Type grep celtic CD_list_new and press Enter
15. Use a command to make all letters uppercase in the CD_list_new file and save the output to a file
called CD_list_uppercase.
16. Use the sed command on the CD_list_new file to replace the words “LIGHT ROCK” with EASY
LISTENING” and the word “ALTERNATIVEwith “EXPERIMENTAL”.
page-pf8
17. Create a file called software with these fields:
Project Number, using the same numbers shown in the project file (which
you created earlier in this chapter)
Software Code, using any three-digit number
Software Description, such as Excel
Then, write a small application joining records in the software file to matching records in the
project file, and use the Awk program to print a report describing the software for each project
you created earlier.
Answer: Type the following in the file:
18. (This exercise is a intended to stretch students.) View the first 20 lines of /etc/termcap. Next, use a
command to change all characters in “version” to upper case for only the first 20 lines in
/etc/termcap.
19. (This exercise is a intended to stretch students.) Find a command to compare the differences
between three files and that creates output for individual lines.

Trusted by Thousands of
Students

Here are what students say about us.

Copyright ©2022 All rights reserved. | CoursePaper is not sponsored or endorsed by any college or university.