You can give a list of files separated by spaces, each of which can include the various UNIX wildcards. Thus the code below would report the name of each NDF and its standard deviation. The NDFs are called `Z' followed by a single character, ccd1, ccd2, ccd3, and spot.
foreach file (Z?.sdf ccd[1-3].sdf spot.sdf)
echo "NDF:" $file:r"; sigma: "`stats $file:r | grep "Standard deviation"`
end
echo writes to standard output, so you can write text including values of shell variables to the screen or redirect it to a file. Thus the output produced by stats is piped (the | is the pipe) into the UNIX grep utility to search for the string "Standard deviation". The ` ` invokes the command, and the resulting standard deviation is substituted.
You might just want to provide an arbitrary list of NDFs as arguments to a generic script. Suppose you had a script called splotem, and you have made it executable with chmod +x splotem.
#!/bin/csh
figaro # Only need be invoked once per process
foreach file ($*)
if (-e $file) then
splot $file:r accept
endif
end
Notice the -e file-comparison operator. It tests whether the file exists or not. (Click here for a full list of the file operators.) To plot a series of spectra stored in NDFs, you just invoke it something like this.
% ./splotem myndf.sdf arc[a-z].sdf hd[0-9]*.sdf
See the glossary for a list of the available wildcards such as the [a-z] in the above example.
C-shell Cookbook