next up previous 405
Next: NDFs
Up: Dealing with Files
Previous: Extracting parts of filenames


Process a Series of Files

One of the most common things you'll want to do, having devised a data-processing path, is to apply those operations to a series of data files. For this you need a foreach...end construct.

     convert               # Only need be invoked once per process
     foreach file (*.fit)
        stats $file
     end
This takes all the FITS files in the current directory and computes the statistics for them using the stats command from KAPPA. file is a shell variable. Each time in the loop file is assigned to the name of the next file of the list between the parentheses. The * is the familiar wildcard which matches any string. Remember when you want to use the shell variable's value you prefix it with a $. Thus $file is the filename.



Subsections

next up previous 405
Next: NDFs
Up: Dealing with Files
Previous: Extracting parts of filenames

C-shell Cookbook
Starlink Cookbook 4
Malcolm J. Currie
2006 November 26
E-mail:ussc@star.rl.ac.uk

Copyright © 2009 Science and Technology Facilities Council