University of Alaska Fairbanks
Geophysical Institute

Beyond the Mouse 2010 - The geoscientist's computational chest.

Lab 8: Unix / Shell Introduction II

"Programming is legitimate and necessary academic endeavor."
Donald E. Knuth

Lab slides

none.

Note

As solution, send me your scripts and the answers to the questions. No datafiles please, I have plenty of those :)

Running the VirtualBox

Check here if you forgot how that works. Really. Go there if you forgot something.

Exercise 0: Permanently changing your Path and stuff

Finish last week's lab: Lab 07!

Exercise 1: Data Handling with awk

Hopefully you remember Exercise 2 of Lab 05. If not, you may remember that, at some point in the past, we had you fiddle with pesky formatting strings to extract some data from a file with a lot more data. This was Exercise 2 of Lab 05. Now we'll go back to the FAIR.pfiles text file and treat it with Unix tools to extract the information we want.

Now that you know how to do those two key actions, create a new tcsh script pfiles2llh in $BTM_BIN, which generalizes this for any .pfiles file it gets as a command line argument. The format for executing this script at the command line should be like this:

> pfiles2llh STATION_NAME.pfiles

Command line arguments are given to a script in various forms. ONE is using the built-in variables $0, $1 ... $N. Inside your script $0 is the program name that has been called. $1, $2, ..., $N are the first argument, 2nd, ..., n-th argument for the program that has been called. This convention is generally used when you have a few arguments that you expect to be handed to the script in a certain order. Here is an interesting article that tells you how to find the maximum number of arguments for a shell command.

Here's what your script is expected to do:

ronni <at> gi <dot> alaska <dot> edu | Last modified: October 31 2011 18:13.