Want more features on Pastebin? Sign Up, it's FREE!


By: a guest on Apr 5th, 2012  |  syntax: None  |  size: 3.91 KB  |  views: 623  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Chapter 5 Review Exercises 1 - 16
  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?
  5. 2. Using sort as a filter, rewrite the following sequence of commands:
  7. $ sort list > temp
  8. $ lpr temp
  9. $ rm temp
  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?
  13. 4. Assume that the following files are in the working directory:
  15. $ ls
  16. intro notesb ref2 section1 section3 section4b
  17. notesa ref1 ref3 section2 section4a sentrev
  19. Give commands for each of the following, using wildcards to express filenames with as a few characters as possible.
  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.
  26. 5. Refer to the documentation of utilities in Part V or the man pages to determine which commands will
  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.
  33. 6. Give a command to
  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.
  39. 7. The lpr and sort utilities accept input either from a file named on the command line or from standard input.
  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.
  44. 8. Give an example of a command that uses grep
  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.
  51. In which of the preceding is grep used as a filter?
  53. 9. Explain the following error message. What filenames would a subsequent ls display?
  55. $ ls
  56. abc abd abe abf abg abh
  58. $ rm abc ab*
  59. rm: cannont remove 'abc': No such file or directory
  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.
  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?
  65. 12. Assume that your permissions allow you to write to a file but not to delete it.
  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.
  70. 13. If you accidentally create a filename that contains a nonprinting character, such as a CONTROL character, how can you rename the file?
  72. 14. Why does the noclobber variable not protect you from overwriting an existing file with cp or mv?
  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.)
  76. 16. Create a file named answer and give the following command:
  78. $ > answers.0102 < answers cat
  80. Explain what the command does and why. What is a more conventional way of expressing this command?
clone this paste RAW Paste Data