Advertisement
Guest User

Untitled

a guest
Apr 5th, 2012
946
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.91 KB | None | 0 0
  1. Chapter 5 Review Exercises 1 - 16
  2.  
  3. 1. What does the shell ordinarily do while a command is executing? What should you do if you do not want to wait for a command to finish before running another command?
  4.  
  5. 2. Using sort as a filter, rewrite the following sequence of commands:
  6.  
  7. $ sort list > temp
  8. $ lpr temp
  9. $ rm temp
  10.  
  11. 3. What is a PID number? Why are these numbers useful when you run processes in the background? Which utility displays the PID numbers of the commands you are running?
  12.  
  13. 4. Assume that the following files are in the working directory:
  14.  
  15. $ ls
  16. intro notesb ref2 section1 section3 section4b
  17. notesa ref1 ref3 section2 section4a sentrev
  18.  
  19. Give commands for each of the following, using wildcards to express filenames with as a few characters as possible.
  20.  
  21. a. List all files that begin with section.
  22. b. List the section1, section2, and section3 files only.
  23. c. List the intro file only.
  24. d. List the section1, section3, ref1, and ref3 files.
  25.  
  26. 5. Refer to the documentation of utilities in Part V or the man pages to determine which commands will
  27.  
  28. a. Output the n umber of lines in the standard input that contain the word a or A
  29. b. Output only the names of the files in the working directory that contain the pattern $(.
  30. c. List the files in the working directory in their reverse alphabetical order.
  31. d. Send a list of files in the working directory to the printer, sorted by size.
  32.  
  33. 6. Give a command to
  34.  
  35. a. Redirect the standard output from a sort command into a file named phone_list. Assume that the input file is named numbers.
  36. b. Translate all occurrences of the characters [ and { to the character (, and all occurrences of the characters ] and } to the character ) in the file permdemos.c. (Hint: Refer to tr on page 804.)
  37. c. Create a file named book that contains the contents of two other files: part1 and part2.
  38.  
  39. 7. The lpr and sort utilities accept input either from a file named on the command line or from standard input.
  40.  
  41. a. Name two other utilities that function in a similar manner.
  42. b. Name a utility that accepts its input only from standard input.
  43.  
  44. 8. Give an example of a command that uses grep
  45.  
  46. a. With both input and output redirected.
  47. b. With only input redirected.
  48. c. With only output redirected.
  49. d. Within a pipe.
  50.  
  51. In which of the preceding is grep used as a filter?
  52.  
  53. 9. Explain the following error message. What filenames would a subsequent ls display?
  54.  
  55. $ ls
  56. abc abd abe abf abg abh
  57.  
  58. $ rm abc ab*
  59. rm: cannont remove 'abc': No such file or directory
  60.  
  61. 10. When you use the redirect output symbol (>) with a command, the shell creates the output file immediately, before the command is executed. Demonstrate that this is true.
  62.  
  63. 11. In experimenting with shells variables, Alex accidentally deletes his PATH variable. he decides that he does not need the PATH variable. Discuss some of the problems he may soon encounter and explain the reasons for these problems. How could he easily return PATH to its original value?
  64.  
  65. 12. Assume that your permissions allow you to write to a file but not to delete it.
  66.  
  67. a. Give a command to empty the file without invoking an editor.
  68. b. Explain how you might have permission to modify a file that you cannot delete.
  69.  
  70. 13. If you accidentally create a filename that contains a nonprinting character, such as a CONTROL character, how can you rename the file?
  71.  
  72. 14. Why does the noclobber variable not protect you from overwriting an existing file with cp or mv?
  73.  
  74. 15. Why do command names and filenames usually not have embedded SPACEs? How would you create a filename containing a SPACE? How would you remove it? (This is a thought exercise, not recommended practice. If you want to experiment, create and work in a directory that contains only your experimental file.)
  75.  
  76. 16. Create a file named answer and give the following command:
  77.  
  78. $ > answers.0102 < answers cat
  79.  
  80. Explain what the command does and why. What is a more conventional way of expressing this command?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement