Home Schedule Reading People
Mac Logo Windows Logo Minix Logo Sun Solaris Logo Linux Logo

Project 4: AWK! Was it something I SED?

Assignment Day March 26, 2012 (Tuesday)
Due Date April 05, 2012 (Thursday) - should be able to do this project within a week

Collaboration Policy - Read Carefully

You must work on this project individually, but you may discuss this assignment with other students in the class and ask and provide help in useful ways, preferable over our email list so we can all benefit from your great ideas. You may consult (but not copy) any outside resources you including books, papers, web sites and people (but no penguins or sea urchins).

If you use resources other than the class materials, indicate what you used along with your answer.

Collaboration Policy - Read Carefully

You must work on this project individually, but you may discuss this assignment with other students in the class and ask and provide help in useful ways, preferable over our email list so we can all benefit from your great ideas. You may consult any outside resources you wish including books, papers, web sites and people (but no penguins or sea urchins).

If you use resources other than the class materials, indicate what you used along with your answer.

Objective:

The main objective for this assignment is to familiarize yourself with a scripting language, specifically gnu's AWK, gawk. You may use the gawk that is already installed on nike or you may install your own gawk.

 

 

 

Tutorials:

Supplements: Precipitation file:

 

Overview:

Your assignment is to create a script, written in gawk, called findrainfall that computes average rainfall in a month in a specific state. The program takes 3 parameters, a US state , a month and an input file containing average amount of rainfall over a 30 year period for about 275 cities in North America.

{saffron:ingrid:221} findrainfall CA february normal.precip.txt

The output of executing the script is the total average rainfall in inches of the particular given state.

As a side note - and a check of your algorithm - the average rainfall for all California cities for February was 2.65067 inches, i.e., your program output should look something like:

{saffron:ingrid:221} findrainfall CA february normal.precip.txt
The average rainfall in February for California was 2.65067 inches.

Helpful Hints:

For your reference program called showmatch (written by Mark) may help in understanding how gawk works:

{h70-33-113-184:ingrid:866} echo "FOO8AB10BAR" | showmatch '[0-9]AB[0-9]'
FOO8AB10BAR
...^^^^

Note that simply searching for the string 'CA' also matches the line CASPER, WY and CHICAGO, IL.

Rainfall File:

The 'database' normal.precip.txt is a TAB delimited file that contains the average amount of rainfall over a 30 year period for about 275 cities in North America. The first line of the file is a header, which tells you what each column contains. Each line following the header contains a city name, the state the city is in, and then average rainfall amounts from January through December, and then an annual average for all months.

Requirements:

findrainfall should be en executable script. It should run on nike. You should develop it in your environment and as a last step, make sure it runs on nike.

Submitting:

Submitting

  1. Create a directory x500_program4.
  2. Put all the materials needed (all awk files) in the above directory (including your README.txt file)
  3. Also include a file, called findrainfall-output.txt containing a 'session' with your program. Please include the output for at least 10 test cases.
  4. Submit via the 'submit' command (while on nike.cs.uga.edu)
{nike:maria} submit x500_program4