Next: 4.7 Where to find Up: 4 Using the programmes Previous: 4.5 Converting data


4.6 Shell scripts

Shell scripts can be written to carry out multiple tasks, for example using convert on many files. For example the following shell script will display converting filename ie. converting data00.dat, run this file through convert producing an output files of converted00.swap and converted00.char (the file extensions are added by convert not the shell script) and finally display finished. This will be carried out for all 48 numbers.



#!/bin/sh

for number in 00 01 02 03 04 05 06 07 08 09 10 
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 
42 43 44 45 46 47
do 
echo converting data$number.dat
./convert data$number.dat converted$number
echo finished
done

Another example of a shell script that may be useful to the user is the following which adds in the dimensions of the file (contained in dims.dat) to the data file (eg pion00.swap and outputs it to another file (eg pion00.dat:



#!/bin/sh

for number in 00 01 02 03 04 05 06 07 08 09 10 
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 
43 44 45 46 47
do
echo pion$number.swap
cat dims.dat pion$number.swap > pion$number.dat
echo pion$number.dat
done

These shell scripts will need to be altered to use the required input and output filenames.


epccssp@epcc.ed.ac.uk
Fri Oct 7 10:31:36 BST 1994