Assignment 2

Due: Thursday, October 9, 2003 11 PM

Background

    In this assignment, in addition to the commands covered in the previous homework, we work with the commands grep and sed.

Part I: The dictionary

    The answers to these questions require using the commands grep or egrep, in some cases wc, and the dictionary file (/home/unixtool/data/words). The dictionary is case sensitive; keep this in mind when writing your grep commands. Also, for the purposes of these questions, y is not a vowel, and a consonant is any character that is not a vowel (including punctuation).

  1. Count the number of words in the dictionary with two vowels next to each other.
  2. Output all the words in the dictionary that have six consonants (non-vowels) in a row.
  3. Count the number of words in the dictionary with the same vowel two (or more) characters in a row (e.g. foot)
  4. Count the number of five letter words in the dictionary.
  5. Count the number of five letter words that do not contain an e.
  6. Output all five letter words that are a palindrome (the same forwards and backward)

Part II: More Weather

    Instead of using the individual weather files, you can use the output from Question 10 from Assignment 1, which I have placed in the directory /home/unixtool/data/weather as the all.daily.

  1. Show days and temperature where the Max temperature is 95 or greater.
  2. Count the number of days where the Max temperature was 70 or greater and the Min tempature was below 50.
  3. Count the number of days where the Max temperature was 70 or greater, or the Min temperature was below 50.
  4. Show which days had rain (note that if the field is 0.00 in or -, there is no rain recorded).

Part III: Shakespeare

    The file /home/unixtool/data/othello.html contains the Shakespeare play Othello. Write sed commands for the following. For each, input is the original file and output is standard out.

  1. Remove the HTML tags (tags are the text between the < character and the > character). For this file, it's OK to assume tags don't span multiple lines.
  2. Make the following changes to the play in a single sed invocation:
            Change the character named Iago to Hugo.
            Change the character named Othello to Odin.
            Remove blank lines
            Add the text <hr> before each scene.
    Put these commands in a separate file to be used with sed.

Turning in the assignment