>>Greetings,
>>I need to process all sub-directories in a particular directory,
>>but not their sub-directories.
>>I have something akin to this:
>> find ${DIR} -type d -print | while read dirname
>> do
>> ... stuff ...
>> done
>>I do NOT want to descend below the directory specified ${DIR} but
>>find recursively descends the directories. I thought -prune is
>>what I want but that's not it either.
>>I know, using GNU find, I can specify -maxdepth 1 but I only can
>>use HPUX 11.0 find(1).
>>I'd be greatful for any pointers.
>Rather than using 'find' you could just use a 'for' loop;
>#!/bin/sh
>DIR=${DIR%/}
>for dirname in $DIR/* $DIR/.[!.]* $DIR/..?*
>do
>[ -d "$dirname" ] &&
> {
> echo "processing directory: $dirname"
> # do whatever...
> }
>done
>line 2 deletes any trailing slash on the directory name (this is
>because some end with / and some don't). then line3 uses 3 patterns
>to match every filename except '.' and '..', then line5 tests
>for a directory and executes the code if it is. it should work
>for directory names with awkward characters like embedded spaces,
>newlines and asterisks, also it should be more efficient with
>resources (since you lose the pipe + extra process).
The note here about directory names with embedded spaces and newlines
only applies to the sub-directories of $DIR. In the case that you want
to be able to deal with $DIR itself possibly containing embedded newlines
and spaces then change line 3 to the following;
for dirname in "$DIR"/* "$DIR"/.[!.]* "$DIR"/..?*
--
: ${L} # http://lf.8k.com