Assignment 7
Home News & Discussion Notes Windows 95 Unix Assignment 4 Assignment 5-A Assignment 5-B Assignment 6 Assignment 7
Updated:
2000-11-18 18:24

Assignment 7 - UNIX

This assignment is for sections taught by Ian Allen.

Hand in:
One printed and hand-annotated telnet session log file in hard copy form.  For full marks, follow the Assignment Submission Standards.  In particular, make sure you use Courier font and annotate your output (see below) before you hand it in.
Preparations:
You must complete the work in the previous Chapters (1, 2, 3, 4, 5, 6, 7, 8, 13, and 22) as well as Chapters 10, 12, 14 and 15 in your Unix text before doing this assignment.

Step 1.  (Readings in Chapters 10, 12, 14 and 15)

Use the vi text editor to type the answers to the following Chapter Reading/Study Exercises into the file named  my10-15answers in your home directory.  Number each answer clearly.  You will find the Chapter Exercises under the Unix button on the course page.
    Put your name and your Algonquin e-mail address at the top of the file.
    Answer the Chapter 14 Exercises 14-2, 14-4, 14-5, 14-8, 14-10, and 14-11.
    Answer the Chapter 15 Exercises 15-1, and 15-5 through 15-9.
    Answer the Chapter 10 Exercises 10-1 through 10-4, and 10-7.
    Answer the Chapter 12 Exercises 12-2 through 12-5.

Put your name and your Algonquin e-mail address at the top of this file.  Number each answer clearly.

Step 2.  (Based on Chapter 14)

Append the answers to the questions in this step to the end of your my10-15answers file.  Number the answers 2-1, 2-2, etc.

Suppose that Ben Dover has a directory called  Recipies in which he stores several hundred recipes, one recipe per file. Each recipe contains information about the ingredients that were used, the cooking time, etc. 
  1. He would like to identify the recipe file names of all the recipes that use wine as an ingredient.  What command line would you advise him to use?  (The output that the command would generate must be just a list of file names of the files that contain the selected ingredient, not the contents of any of the files.)
  2. What command line could he use to have both the list of file names and a count of the number of files found printed at the same time?  (The one command line would generate both the file names and the count of the file names found.)
  3. Give a command line that would generate the same information as the previous question, using the ingredient food colouring .  The spelling of colouring might be Canadian or American (coloring).  Find both.

Step 3.  (Based on Section 5.3)

The wildcard pathname pattern matching abilities of the Unix shells differ from that of grep, egrep, and sed in that the shells do not use regular expressions to match pathnames. 

Shell pathname wildcards are often called "globbing" (taken from "global" pattern matching) to distinguish them from regular expressions.  Some of the metacharacters are the same beetween globbing and regular expressions; but, they have different meanings.

Ben Dover's wife, Eileen Dover, has a directory of recipe file names as listed below:
	eggplant.cacciatore
	eggplant.divan
	pot.au.feu.1
        pot.au.feu.2
        pot.au.feu.3
        pot.au.feu.A
        pot.au.feu.B
        pot.au.feu.C
	hearty.bean.soup
	split.pea.soup
	soup.supreme
	caribbean.eggplant
	hot.apple.sandwich	
Create a recipe directory and then create all these empty files with one or more touch commands.  (You can copy the above list of names from this web page, paste it into a file, and use that file in a Unix command to create all the empty files without typing each one in individually.)

Creating the above directory of file names allows you to test and demonstrate the following commands about shell globbing:

  1. Eileen would like to list only the soup recipe file names.  Demonstrate a Unix command that does this.
  2. Type a Unix command that lists only those file names that have soup as the last word.
  3. Type a single command line that lists the file names of all the eggplant and apple recipes.
  4. Give a command line that matches recipies ending in a digit (0 through 9).

Step 4.  (Based on Chapter 14)

Create the regexp file (pp.619-620 of the text).  This file must be typed exactly as shown.  Do not add extra spaces after the ends of lines.  You can turn on an option in vi to show you the locations of the ends of lines.[p.186]  You can use the command /thome/alleni/dat2333/datdiff  to tell you if your copy of the file has typing errors in it:
$ /thome/alleni/dat2333/datdiff regexp
- regexp differ: char 16, line 3

The above output would indicate that you have a typing error on line 3 of your file, at the 16th character from the start of the file.  Fix the file before you begin.

Practice issuing the following commands.  Pay extremely close attention to the command name and quoting used, and to the exact characters inside the single quotes.

	grep    '^the'   regexp
	grep    'that\$' regexp
	grep    '[^a-z]' regexp
	grep    '[^0-9]' regexp
	grep -v '\^'     regexp
	grep -v '.'      regexp

Step 5.  (Based on Chapter 14)

Create the test-extend file (p.642 of the text).  This file must be typed exactly as shown.  You can use the command /thome/alleni/dat2333/datdiff  to tell you if your copy of the file has typing errors in it:
$ /thome/alleni/dat2333/datdiff test-extend
cmp: EOF on test-extend

The above output would indicate that your file is shorter than the actual test file.  (The compare program hit end-of-file on your file before it reached the end of the test file.)  Fix the file before you begin.

Practice issuing the following commands.   Pay extremely close attention to the command name and quoting used, and to the exact characters inside the single quotes.

	egrep 'xY+'       test-extend
	egrep '0(xY)+'    test-extend
	egrep '^(xY|Yx)'  test-extend

Step 6.  (Based on Chapter 15)

Create the gdbase file (pp.651-2 in the text), the add-item file (p.662), and the comment.file (p.664), and then issue the following commands lines:
	sed -e 's/Hshld/HSHLD/'             gdbase
	sed -e '/^Cheese/s/1/2/g'           gdbase	
	sed -e '/^Cheese/,/^Floor/s/y$/n/'  gdbase
	sed -f add_item                     gdbase
	sed -e '/^Fish/r comment.file'      gdbase

Make sure the output is correct for each of the above expressions!

As explained on p.661, the use of "-e" to signal the argument containing the instructions to be executed is optional when only one action is being performed.

Step 7.  (Creating the Telnet Log File)

You need to have done all the readings, completed all the prerequisite Chapters, and completed all previous steps of this Assignment to do this logging Step.

Login to Unix and then turn on telnet logging to record the following Unix session on your A: diskette or on your N: drive.  When asked to display the contents a file or script, use the  cat command.  (For full marks, do not use an editor or any commands that paginate the file, since the pagination mis-formats the display of the file in the log.)  Perform the following actions for the log file: 

  1. Set your shell prompt to be your current working directory.
  2. Display the contents of your HOME environment variable.
  3. Display the current date.
  4. Display the contents of the file my10-15answers that you created in Steps 1 and 2.
  5. Change to your recipies directory that you created in Step 3 and perform the actions of Step 3.
  6. Using your copy of the regexp file from Step 4, enter the command:
          /thome/alleni/dat2333/datdiff regexp 
    You should see no output, indicating that your file is correctly typed in.
  7. Execute the commands of Step 4.
  8. Using your copy of the test-extend file from Step 5, enter the command:
          /thome/alleni/dat2333/datdiff test-extend 
    You should see no output, indicating that your file is correctly typed in.
  9. Execute the commands of Step 5.
  10. Enter the directory that contains the three files used in Step 6.
  11. Display the contents of the gdbase file.
  12. Display the contents of the add-item  file
  13. Display the contents of the comment.file file.
  14. Execute the commands of Step 6.
  15. Display the current date.

Turn off telnet logging.  Print the Telnet log file using a monospace (Courier) font.  Choose the font size so that the contents of your answer file looks neat and prints without line wrapping.

Step 8.  (Annotating the Telnet Log File)

 Annotate your printed Telnet log file output by hand as follows:

  1. Take a pen or marker and draw long, page-width lines between each of the numbered actions you performed in the previous step.
  2. Write in (using pen or marker) the number of the action beside each of the actions.  Use the action numbers given in the previous step.
  3. Highlight or underline each of the Unix command lines you typed to the shell to do the actions in the previous step.  Do not highlight the output of the command lines.  Highlight only the Unix command lines that you typed in.

There is only one telnet session log file to hand in.  It comes from the Telnet Log File step.  Do not log or hand in anything else other than the one log file from the Telnet Log File step.  Make sure you annotate the log file by hand as required in the Annotating step.  

Web Author: Ian! D. Allen idallen@ncf.ca
Updated: 2000-11-18 18:24