Assignment I

General instructions for all assignments

Provide an answer for each item in each session.
When the answer to the item is a Unix command, show the command and the system's response.
When the system prints more than 5 lines, abbreviate the response to 5 lines (unless more lines are specifically requested), showing the most important parts.
Use vi to create a file for each session, for example, create a file named sessionI1

Session I1

This section contains short answer questions. You may use the computer to test your answers, but only the answers are required.

  1. Simplify the following regular expressions:
  2. If possible, rewrite the following regular expressions using other operators:
  3. What is the difference between the following two regular expressions:
  4. Given the following regular expression:   [^A-G]   which of the following lines are matched by this regular expression? For those that match, identify which characters are matched.
  5. Given the following regular expression:   ^[ABC][^AB]$   which of the following lines are matched by the regular expression?
  6. Given the following regular expression:   \..\{3\}$   which of the following lines are matched by the regular expression?
  7. Given the following regular expression:   ^[^\$]$   which of the following lines are matched by this regular expression? For those that match, identify which characters are matched.
  8. Given the following regular expression:   ^\$[0-9]*[^0-9]$   which of the following lines are matched by this regular expression? For those that match, identify which characters are matched.
  9. Write a regular expression that matches a line with exactly three characters.
  10. Write a regular expression that matches a password in the following format:   llddUU~~   where each l is any lower case letter, each d is any digit, each U is any upper case letter, and each ~ is any character that is neither a letter nor a digit.
  11. Write a regular expression that matches a non-digit character.

Session I2

  1. Log into the system.
  2. Create a file named   AIS2F1   containing the following data. (Do not type the headings.)
    ID	Name	Hours	Hourly
    		Worked	Pay
    
    1425	Juan	18	14.25
    4321	George	22	21.11
    6781	Anne	44	16.77
    1451	Ben	36	21.77
    2277	Tuan	16	38.77
          
    In your answers, do not depend on any other information, which you may know, except the data provided in the question.
  3. Use a single command line to display only the Hourly Pay of Anne
  4. Use a single command line to display only the Name of the employee with ID 1451
  5. Use a single command line to display only the Names of all employees who worked 20 hours or more (You may wish to extract the second and third fields before using grep).
  6. Use a single command line to display the ID and Hours Worked for all employees who have an Hourly Pay of 20.00 or more.
  7. Use a single command line to display the ID, Name, and Hourly Pay for all workers who worked fewer than 20 hours.

Submission session

Create a heading similar to the heading for assignment A.

Tommy Atkins   replace with your name
CIS 18A    
Winter 2011   replace with the current quarter
Assignment I  replace with the current assignment letter

  1. Use the following command to create a file with your work from the assignment:
    cat headingI sessionI1 sessionI2 > assignmentI.txt
  2. Use e-mail or WinSCP to obtain a copy of assignmentA.txt. Print it using notepad, or otherwise use the Courier New or other mono-space font.
  3. Turn in your printout to the instructor on time.