[ug-bosug] 'find' -maxdepth alternate

Moinak Ghosh Moinak.Ghosh at Sun.COM
Mon Jan 22 10:31:34 PST 2007


you'd need to use the following shell snippet:

find . | while read f
do
    cnt=`echo $f | sed 's/\// /g' | wc -w`
    if [ $cnt -lt <maxdepth> ]
    then
        echo $f
    fi
done

AFAIK there is no direct replacement.

Regards,
Moinak.

Anil Gulecha wrote:
> Hi list,
>
> I'm working on the USB session manager for Belenix, and for a part of 
> the script I need to print out the files in the mentioned directory.
>
> For Ex:
> # find /tmp/parentdir/
> /tmp/parentdir/
> /tmp/parentdir/childdir1
> /tmp/parentdir/childdir1/file
> /tmp/parentdir/childdir2
> /tmp/parentdir/childdir2/file
> /tmp/parentdir/childdir3
> /tmp/parentdir/childdir3/file
> /tmp/parentdir/file1
> /tmp/parentdir/file2
> /tmp/parentdir/file3
> # find /tmp/parentdir/ -type f
> /tmp/parentdir/childdir1/file
> /tmp/parentdir/childdir2/file
> /tmp/parentdir/childdir3/file
> /tmp/parentdir/file1
> /tmp/parentdir/file2
> /tmp/parentdir/file3
>
> I'm trying to figureout somehting that'll only print out:
> # find <mystery options>
> /tmp/parentdir/file1
> /tmp/parentdir/file2
> /tmp/parentdir/file3
>
> GNU find has the -maxdepth option, and I'm unable to find it on the 
> solaris find
>
> Regards
> Anil
> ------------------------------------------------------------------------
>
> _______________________________________________
> ug-bosug mailing list
> List-Unsubscribe: mailto:ug-bosug-unsubscribe at opensolaris.org
> List-Owner: mailto:ug-bosug-owner at opensolaris.org
> List-Archives: http://www.opensolaris.org/jive/forum.jspa?forumID=54
>   




More information about the ug-bosug mailing list