[Sunhelp] csh scripting problem

Ben Dougherty benjamind at miles33.co.uk
Thu Jun 22 04:37:07 CDT 2000


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).

I tried to get around this with the following
command:

---------------

set name = `echo $subdir | nawk '{gsub(" ","\\ ", $0); print $0}'`

---------------

which places a "\ " for every " " in the
filename, which worked but for some reason
that didn't work with (-d $name). <shrug>

Can anyone help me with this problem cus I
don't want to have to write it in 'c'.

Thanks for any help
Ben.






More information about the SunHELP mailing list