Networking Chapter 4 Homework You are starting a new year and need to create ten empty files

subject Type Homework Help
subject Pages 7
subject Words 2512
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 4 Solutions
Answers to the Chapter 4 Review Questions
1. You are starting a new year and need to create ten empty files for your accounting system. Which
of the following commands or operators enable you to quickly create these files? (Choose all that
apply.)
2. Your project team uses a group of the same files and tracks whether they are still in use by looking
at the last modified date. You need to show that a series of files are still in use by changing the last
modified date to today. What command do you use?
3. Which of the following are ways in which you can structure a record containing data? (Choose all
that apply.)
4. You need to delete 30 files that all start with the letters customer, such as customer_accounts,
customer_number, and so on. Which of the following commands enables you to quickly delete
these files?
5. You are in your home directory and need to copy the file MemoRequest to a folder under your
home directory called Memos. Which of the following commands do you use?
6. You have a personnel file that contains the names, addresses, and telephone numbers of all
employees. The first field in the personnel file is the employee number and the second field is the
employee last name. The third field is the first name and middle initial. Because there are no
employees with the same last name, you want to check the file by last name to make certain all
employees are included. Which of the following commands should you use?
7. You are doing some “house cleaning” and want to delete several empty directories. Which of the
following commands can you use? (Choose all that apply.)
8. You are trying to use the command sort t: +5 datastore, but you get an error message each time
you try it. How can you save the error message in a file called error, so you can e-mail the file to
your computer support person?
9. Which of the following commands would you use to make a backup copy of the file AR2008?
10. You have a lot of subdirectories under your home directory and know that you saved the file
supplemental in one of them, but you are not sure which one. After you use cd to change to your
home directory, which of the following commands enables you to search all of your subdirectories
page-pf2
11. You have created a script file called sum_report in your home directory and have made it
executable. What command do you use to run the script?
12. Standard output is referred to as which of the following?
13. Which of the following conditions must be met for you to combine two files using the join
command? (Choose all that apply.)
14. Which of the following commands can you use to sort the file vendor_name and display the
results on the screen?
15. When you use the paste command, columns of information are separated by a tab. However, your
boss wants the columns separated by a colon. What option enables you to specify the colon as the
separator?
16. You are examining your addresses file, which contains the first and last names of people you
know as well as their street address, city, state, zip code, and telephone number. You want to print
a list of last names, which is field 1, and telephone numbers, which is field 7. Which of the
following commands enables you to print this list?
17. You keep a yearly record of the birds you’ve seen in your town. The name of the file is birds. The
file contains the following fields name (field 1), markings (field 2), year(s) viewed (field 3), and
location (field 4). You want to review the contents of the file, sorted by location. Which of the
following commands do you use?
18. Which of the following can be accomplished with the mv command? (Choose all that apply.)
19. Your boss asks you to create a professional-looking report from the contents of two files. Which
of the following tools enables you to produce a polished report?
20. What command enables you to sort the contents of a file in reverse order?
21. You want to combine two files, data07 and data08, into a file called data_all. Which of the
following commands do you use?
22. How can you use the touch command to create four new files called sum, datanew, results, and
calcs (using one command line)?
23. Create a command that sorts on the second field in the file addresses, and then writes the sorted
results to the new file sorted_addresses.
page-pf3
3
24. Create a command that enables you to copy all of the files in the spreadsheets directory to the
accounts directory (when both directories are first-level directories under your home directory and
you are currently in your home directory).
25. You play guitar and keep two files on your computer. One file, called strings, lists the different
brands of strings you keep on hand. Another file, called music, lists the music books and scores
you own. When you enter the command paste strings music, what happens?
Hands-On Projects Tips and Solutions for Chapter 4
Project 4-1
Students learn to use a command file to input commands to the vi editor. Note that the commands work
most reliably when they are together on one line than if they are on separate lines.
Consider holding a discussion with your class to consider ways in which redirection techniques can
save time and automate activities.
Project 4-2
This project enables students to redirect an error message to a file. Consider discussing in class how
this capability might be used for programming and system administration techniques.
Project 4-3
In this project, students create an empty file using the > redirection symbol.
Project 4-4
.
For this project, students use the touch command to create a file and then to change its timestamp.
Project 4-5
In this project, students delete individual files and multiple files using a wildcard.
Project 4-6
In this project, students use both the rmdir and the rm -r commands to delete directories. Consider
holding a discussion about times in which you and others in the class have inadvertently deleted files
and folders you did not intend to delete. Next, discuss precautions that might be taken to avoid this
problem.
Project 4-7
For this project, students practice using the cp command to copy and back up files.
page-pf4
4
Project 4-8
This project enables students to use the move command, including moving multiple files at the same
time.
Project 4-9
Project 4-10
In this project, students gain more experience using the cat command and a redirection operator to
create a simple data file. Next, they use cat and the redirection operator to combine two files into a
third file. Consider discussing in class situations in which it can be faster to use cat than the vi or
Emacs editors and the limitations of using cat.
Project 4-11
Project 4-12
This project is divided into three sections of steps. In the first section, students create two types of data
files, one containing variable length records and one containing fixed length records.
Project 4-13
For this project, students learn more about working with variable and fixed length records in files.
They use the sort command on each type of file. Also, they learn how to write the results of the sort
command either to the screen or to a file.
Project 4-14
Project 4-15
page-pf5
This project enables students to create and run their first shell script. This is only intended to enable
students to get their “feet wet” at this point and to begin thinking about the use of shell scripts.
Project 4-16
In this project, students get a first taste of using the join command to create a report.
Project 4-17
Project 4-18
Through this project, students create an Awk program script file and then use it within the awk
command.
Discovery Exercises
1. How can you create a file called history by using a redirection operator?
2. Wait one minute or more and then change the timestamp on the history file you just created.
3. Back up the history file to the file history.bak.
5. Create and use a command that displays only the last names and telephone numbers (omitting the
area code) of people in the corp_phones2 file. Place a space between the telephone number and the
last name.
What command can you use to copy the data1 and data2 files from your current working directory
to the datafiles directory?
7. Assume you have four files: accounts1, accounts2, accounts3, and accounts4. Write the paste
command that combines these files and separates the fields on each line with a “/” character,
displaying the results to the screen.
page-pf6
6
8. How would you perform the action in Discovery Exercise 7, but write the results to the file
total_accounts?
9. Assume you have 10 subdirectories and you want to locate all files that end with the extension
“.c”. What command can you use to search all 10 of your subdirectories for this file?
10. After you create a script file, what are the next steps to run it?
“Product” and the name of the report is “Vendor Data.”
12. Create the subdirectory mytest. Copy a file into your new subdirectory. Delete the mytest
subdirectory and its contents using one command..
13. Use the cut command to create a file called descriptions that contains only the product descriptions
from the products file you created earlier in this chapter.
14. You are worried about copying over an existing or newer file in another directory when you use
the move command. What are your options in this situation?
15. What command enables you to find all empty files in your source directory?
16. How can you find all files in your home directory that were modified in the last seven days?
17. How can you put the contents of each line of the product1 file side by side with the contents of the
product2 file, but with only a dash in between instead of a tab?
18. Make a copy of the corp_phones2 file and call it testcorp. Next create a single-line command that
enables you to cut characters in the fifth column of the testcorp file and paste them back to the first
page-pf7
column in the same file? (Hint: Two good solutions exist, one in which you use a semicolon and
one with more finesse in which you use a pipe character.)
19. How can you use a command you have learned in this chapter to list the names of all users on your
system? (Hint: Find out the name of the file in which user information is stored.)
20. Type who and press Enter to view a list of logged-in users, along with other information. Now use
the who command (which you learned about in Chapter 1) with a command you learned in this
chapter to view who is logged in, but to suppress all other information that normally accompanies
the who command.

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.