Assignment 3: various exercises in UNIX shell

2 - A:

Write a script which accepts a two letter sequence as input, and if that sequence represents the code of a US State or territory (as contained in the file /home/SRUNET/david.dailey/public_html/postal.html ) (see here for a reference and a web-view), returns, as output, the name of that state.

The program would run as shown here: 

$ ./lookup MN
Minnesota
$

2 - B:

Write a script which takes, as input, an alphabetic string, such as "Slippery Rock". If the string represents the name of a city or town in the United States (as listed in /home/SRUNET/david.dailey/data/Gaz_places_national.txt, *), the program should return a list of the names of all states in which it appears. Note: there are places like Inver Grove Heights, CA that have more than two words in the place name.

The program would run as shown here: 

$ ./place Slippery Rock
Pennsylvania
$

2 - C:

Write a UNIX shell script which takes the first six letters of your name(s) (including first and last names, as needed to get six letters) and produces a six by six html table (visible at

 http://obsidian.sru.edu/users/<username>/table.html 

in which the jth entry in the ith column contains the number of words in the the file /usr/share/dict/linux.words that begin with the letter i and end with the letter j.

b) generalize it so that it will take any string as an input parameter from the command line.

2 - D:

 -- Write  a unix script at the top level of your account (the file should have world execute but not world read privs) which takes two words (parameters) as input from the command line and produces, as output, the number of different letters the two words have in common, followed by a list (in any order) of those letters. The output should be formatted as shown in the example below:

$ ./common sample remunerate
The words "resample" and "enumerated" share these 4 letters:
"r", "a", "m", and "e".

100% credit on part D, if you can do it without creating any temporary files (be sure to mention this in your email to me). 90% if you succeed, but use temporary files.


* places.txt - a list of US placenames from the 1990 US census bureau
including name of incorporated place, state, population, latitude and longitude.
Record layout can be seen at

https://www.census.gov/geo/maps-data/data/gazetteer1990.html

Note: more current data can be found at https://www.census.gov/geo/maps-data/data/gazetteer2010.html  -- It is now copied into /home/SRUNET/david.dailey/data/Gaz_places_national.txt. Please don't make your own copy -- just point to this one!