[Nottingham] bash scripting - gotme

John Morrison john.r.morrison at ntlworld.com
Wed Oct 13 11:57:13 BST 2004


> Morning!
> I've been got by some bash scripting I've been trying to sort out for
> someone in my office, and haven't been able to work out how to get round
> it.  I hoped someone wiser (but not necessarily older ;-)) might be able
> help...
>
> The setup is this; we have another script that does a bunch of image
> analysis, but it needs to run from in the relavant folder.  There a
> quite a few folders, and the aim is to write a script to automate the
> task (i.e. cd into a folder, run the analysis script, cd .., cd into the
> next folder...). So far, we've got the each folder name assigned to
> variable i.e.
>
> $a1=folder1
> $a2=folder2
> ...
> $an=foldern

as long as there are no spaces in the folder names...

for f in folder1 folder2 folder3 ; do
cd $f
# run script
cd -
done

should work :)

J.




More information about the Nottingham mailing list