Review Exercise 4
Sobell, Chapter 12 (pg 476-477)
Awk Class Notes or AWK book Chapter 1-2
Due Date: 3/1/02


Please complete the following Review Exercises.
Place your answers underneath each question using a
Unix text editor.  Turn in your answers as follows: turnin ex4 exercise4.txt 

1. Assume you are working with the following history list:

   37 pine alex
   38 cd /home/jenny/correspondence/business/cheese_co
   39 pg letter.0321
   40 vi letter.0321
   41 cp letter.0321 letter.0325
   42 grep hansen letter.0325
   43 vi letter.0325
   44 lp letter*
   45 cd ../milk_co
   46 pwd
   47 vi wilson.0321 wilson.0329

   Using the history mechanism, give commands to do each of the following:

   a. Send mail to Alex
   b. Use vi to edit a file named wilson.0329
   c. Send wilson.0329 to the printer

2. How can you identify all the aliases currently in effect?

3. How can you make tcsh always display the pathname of the working directory 
   as part of its prompt?

4. Give the AWK commands to perform the following:

   a. Print the total number of input lines
   b. Print the total number of lines that contain Unix
   c. Print every line with more than four fields
   d. Print every line that has a least one field
   e. Print every line with the first field replaced by the line number 

5. Explain the difference between the BEGIN and END patterns.

6. Explain the difference between the AWK built-in variables, NR, NF, $1, $0

7. If the variable A has a value of 10, what is the value after
   the following operations on A (assume A is equal to 10 at the beginning
   of each question):

   a.  A++
   b.  A = A + 3.5
   c.  A += 7 
   d.  A = A * 3 
   e.  A -= 10 

8. How many times will the following AWK for loop iterate:

	for (i = 0; i <= 100; i += 2)
		print "hello"

9. Which strings would the regular expression AB*C match:

    a. AB
    b. AC
    c. ABC
    d. ABBC
    e. ACC
    f. BC