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.
- Simplify the following regular expressions:
- [ABCDE]
- [ABCDEnmopqr]
- [0123456]
- [ABCDEa-q]
- If possible, rewrite the following regular expressions using other operators:
- A\{0,\}
- A{1,}
- A{0,1}
- A{2,3}
- What is the difference between the following two regular expressions:
- 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.
- Given the following regular expression: ^[ABC][^AB]$
which of the following lines are matched by the regular expression?
- Given the following regular expression: \..\{3\}$
which of the following lines are matched by the regular expression?
- rs.efg$tu
- abc.def
- abc.$$$
- abc.$$$$
- 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.
- 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.
- Write a regular expression that matches a line with exactly three characters.
- 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.
- Write a regular expression that matches a non-digit character.
Session I2
- Log into the system.
- 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.
- Use a single command line to display only the Hourly Pay of Anne
- Use a single command line to display only the Name of the employee with ID 1451
- 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).
- 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.
- 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
- Use the following command to create a file with your work from the assignment:
cat headingI sessionI1 sessionI2 > assignmentI.txt
-
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.
- Turn in your printout to the instructor on time.