2015 Words9 Pages
UID: ______ Name: ________________ ____________________ Date: October 28, 2012

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…
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.

Answer: Type uniq CD_list CD_list_new and press Enter.

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

Answer: Type sed s/misc/other/ CD_list_new > CD_list_replace and press Enter. Type comm CD_list CD_list_replace and press Enter. You might mention to students that another to do this is to type sed s/misc/other/ CD_list_new | cat > CD_list_replace.

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.

Answer: Type tr ‘[a-z]’ ‘[A-Z]’ < CD_list_new > CD_list_uppercase and press Enter. Another solution is to type tr ‘[a-z]’ ‘[A-Z]’ < CD_list_new | cat > CD_list_uppercase and press Enter.

16. Use the sed command on the CD_list_new file to replace the words “light rock” with “easy listening” and the word “alternative” with “experimental”.

Answer: Type sed s/”LIGHT ROCK”/”EASY
Open Document