HWR 597A -- Assignment 2

Reading:

Objectives:


Homework exercises (due 10:00 am, February 22, 2002):

1. Make a directory called ~/h597/2. Set protection so only you can read and write in this directory.

2. For this assignment, we will download daily hydrogen peroxide (H2O2) concentrations taken as Summit, Greenland in 2000. We will determine which day had the most measurments and then create a file with only that day and its values. We will work with this data in the next assignment as well.

Go to: http://www.hwr.arizona.edu/~Polar/UA/2000/h2o2_air/ua_h2o2_concen_00 and save this file to your ~/h597/2 directory. Delete everything but the actual numeric values in this file, make sure you delete the ^M characters. Use unix2dos file > newfile.

3. You will create a Bourne shell script to determine which day contains the most measurements and then write only that days and its H2O2 measurements to a new file. Name your script: "do_h2o2".

4. Your script should first check that you have the correct number of command-line arguments, in this case: one. The only argument should be the data file name, in this case "ua_h2o2_concen_00". Your script should complain and exit if the user does not specify a filename at the command line.

5. Your script should then check that this file does indeed exist and should complain and exit if is does not.

6. Your script should then prompt the user for an output filename and read that in.

7. Your script should then use a combination of the cut, field, sort, uniq, tr and head commands to:

Here is a sample running of the program "try_h2o2" which you can run. First, make sure the directory which contains your datafile has permissions 775, e.g. chmod 775 ~/h597/hw2. Also make sure that ~h597/bin is in your PATH.

% try_h2o2 ua_h2o2_concen_00.txt
Please enter output filename:
junk.out
processing file: ua_h2o2_concen_00.txt, day number: 178
output stored in file: junk.out
% head junk.out
Year H2O2 ppbv
178.989583 0.26
178.975694 0.30
178.961806 0.22
178.947917 0.18
178.927083 0.15
178.920139 0.25
8. Your script should be well-commented and robust. Make sure you test it out with bad data. I will test it when I grade it.

9. turnin hw2 do_h2o2