CS 2204: Homework #2
What to turn in: A legible paper copy giving your answers
Write egrep commands to operate on an this sample.txt file that
catch the patterns specified. A correct answer finds ALL occurences of the
specified pattern and nothing else.
- (2 points) Find all lines containing US postal abbreviations for states (you can assume that a postal abbreviation is two uppercase letters).
- (1 point) Find all lines listing US city references. A US city reference is like Portland, OR , i.e., a word, followed by a comma, a space, and then a two-letter state abbreviation.
- (2 points) Find all lines listing university courses. A university course is a word, followed by a space, followed by exactly four digits.
- (2 point) Find all lines containing formatted dollar amounts. These begin with a $ , followed by a whole dollar amount (i.e., a succession of one or more digits), then a period . , and finally, exactly two digits denoting the cents. Remember, that $ is a metacharacter, and
therefore requires special treatment.
- (2 points) Find all Russian last names in sample.txt. Russian last names end in 'ev', 'ov', 'off' or 'in'.
- (1 point) Find all blank lines, i.e., lines containing nothing.