Study Guide for Lab Quiz 3 CHAPTER 5 - 6
Chapter 5 Discovery Exercises
1. Use a command to find the instances in which the word “host” is used in the /etc directory.
Answer: Type grep host /etc/* and press Enter.
2. What addition to the command you used in Exercise 1 can you use to slow the output to one screen at a time?
Answer: Add a pipe and use more or less, as in grep host /etc/* | more or grep host /etc/* | less.
3. How can you determine the number of lines and words in the /etc/termcap file?
Answer: Type wc -lw /etc/termcap and press Enter.
Note: For students using …show more content…
7. Use a command to compare the trees and more_trees files and show the differences in terms of individual lines that differ.
Answer: Type diff trees more_trees and press Enter.
8. Determine the number of bytes in both the trees and more_trees files using a one-line command.
Answer: Type wc -c trees more_trees and press Enter.
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.
10. Create a new file, CD_list, and enter these lines in the file:
Use the sed command and a script file to add these lines to the end of the CD_list file:
Answer: 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: