[Sunhelp] Re: csh scripting problem
Steffen Grunewald
steffen at gfz-potsdam.de
Thu Jun 22 04:42:17 CDT 2000
On Thu 2000-06-22 (09:37), Ben Dougherty wrote:
> Hi all,
>
> I'm having problems trying to write a small script
> which will recursively step through a directory
> structure writing a file within each directory.
> I started with the following:
>
> ---------------
>
> # script name = "mpu_gen"
> #!/bin/csh
>
> echo start mpu_gen var_path = $cwd
>
> foreach file (*)
>
> if ( -d $file ) then
> cd $file
> /usr/local/scripts/mpu_gen
> endif
> end
>
> ---------------
>
> Now this works most of the time but when I get
> directories with spaces in the name, it throws
> a wobbley (-d $file doesn't work).
Did you try to replace all occurrences of $file by "$file" ?
BTW, the #! line has to be the first one in the script...
--
Steffen Grunewald * GeoForschungsZentrum (GFZ) Potsdam * Projektbereich 2.2
Telegrafenberg E3 * D-14473 Potsdam * Germany / Duitsland / Allemagne
steffen(at)gfz-potsdam.de, steffen.grunewald(at)gmx.de, 9311356(at)scall.de
"Art is a lie which makes us realize the truth" - Pablo Picasso
More information about the SunHELP
mailing list