none.
As solution, send me your scripts and the answers to the questions. No datafiles please, I have plenty of those :)
Check here if you forgot how that works. Really. Go there if you forgot something.
Finish last week's lab: Lab 07!
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.
FAIR.pfiles
file that has been passed using
awk
(HINT: separate variables with a comma in the print statement and they will be separated by a space in the output).FAIR2.llh
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:
$#
to test for the
existence of an argument (i.e. give error/usage message when there is NO/too many arguments)..pfiles
file that has been passed using awk
(you did this above)STATION_NAME.llh
:pfiles
file is named following the convention STATION_NAME.pfiles
STATION_NAME
using the program basename
; save the value to a
variable inside your script (e.g. sta_name
)dirname
. Again, save the result to a variable in
the script (e.g. sta_path
).awk
call into ${sta_path}/${sta_name}.llh
echo
the values of the variables you set for testing, to make sure you're doing things right!ronni <at> gi <dot> alaska <dot> edu | Last modified: February 01 2013 21:40.