| |
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.
- 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.)
- 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.)
- 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:
- Eileen would like to list only the soup
recipe file names. Demonstrate a Unix command that does this.
- Type a Unix command that lists only those file names that have soup as the last word.
- Type a single command line that lists the file names of all the eggplant
and apple recipes.
- 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:
- Set your shell prompt to be your current working directory.
- Display the contents of your HOME
environment variable.
- Display the current date.
- Display the contents of the file my10-15answers
that you created in Steps 1 and 2.
- Change to your recipies directory that you created in Step 3 and perform
the actions of Step 3.
- 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.
- Execute the commands of Step 4.
- 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.
- Execute the commands of Step 5.
- Enter the directory that contains the three files used in Step 6.
- Display the contents of the gdbase
file.
- Display the contents of the add-item
file
- Display the contents of the comment.file
file.
- Execute the commands of Step 6.
- 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:
- Take a pen or marker and draw long, page-width lines between each of the
numbered actions you performed in the previous step.
- 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.
- 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.
|