Exercises


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?

2.

Using sort as a filter, rewrite the following sequence of commands:

$ sort list > temp $ lpr temp $ rm temp 


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?

4.

Assume that the following files are in the working directory:

$ ls intro      notesb     ref2      section1    section3    section4b notesa     ref1       ref3      section2    section4a   sentrev 


Give commands for each of the following, using wildcards to express filenames with as few characters as possible.

  1. List all files that begin with section.

  2. List the section1, section2, and section3 files only.

  3. List the intro file only.

  4. List the section1, section3,ref1, and ref3 files.

5.

Refer to the documentation of utilities in Part V or the man pages to determine which commands will

  1. Output the number of lines in the standard input that contain the word a or A.

  2. Output only the names of the files in the working directory that contain the pattern $(.

  3. List the files in the working directory in their reverse alphabetical order.

  4. Send a list of files in the working directory to the printer, sorted by size.

6.

Give a command to

  1. Redirect the standard output from a sort command into a file named phone_list. Assume that the input file is named numbers.

  2. Translate all occurrences of the characters [ and { to the character (, and all occurrences of the characters ] and } to the character ) in the file named permdemos.c. (Hint: Refer to tr on page 879.)

  3. Create a file named book that contains the contents of two other files: part1 and part2.

7.

The lpr and sort utilities accept input either from a file named on the command line or from standard input.

  1. Name two other utilities that function in a similar manner.

  2. Name a utility that accepts its input only from standard input.

8.

Give an example of a command that uses grep

  1. With both input and output redirected.

  2. With only input redirected.

  3. With only output redirected.

  4. Within a pipe.

  5. In which of the preceding is grep used as a filter?

9.

Explain the following error message. What filenames would a subsequent ls display?

$ ls abc  abd  abe  abf  abg  abh $ rm abc ab* rm: cannot remove 'abc': No such file or directory 





A Practical Guide to UNIX[r] for Mac OS[r] X Users
A Practical Guide to UNIX for Mac OS X Users
ISBN: 0131863339
EAN: 2147483647
Year: 2005
Pages: 234

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net