[ug-bosug] 'find' -maxdepth alternate
Anil Gulecha
anil.verve at gmail.com
Mon Jan 22 20:47:30 PST 2007
On 1/23/07, Moinak Ghosh <Moinak.Ghosh at sun.com> wrote:
>
> Anil Gulecha wrote:
> >
> >
> > On 1/23/07, *Moinak Ghosh* <Moinak.Ghosh at sun.com
> > <mailto:Moinak.Ghosh at sun.com>> wrote:
> >
> > 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.
> >
> >
> > In this case we are traversing the entire structure, just not printing
> > it out. this is unacceptable as the script will be looking for
> > specific files, and taring them up.
>
> It does print. The default for find is to print - try it. And you can
> provide
> any arbitrary maxdepth.
I should have phrased my sentence better. yes, it does print, but the
script traverses the _whole_ file system, printing _only_ what we ask. This
takes a lot of time for say / or /etc/
the
find /DIR/. \( -type d \! -name . -prune \) -o -type f -print command only
looks for the required files and is thus very fast.
Regards
Anil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.opensolaris.org/pipermail/ug-bosug/attachments/20070123/8ed9515e/attachment.html
More information about the ug-bosug
mailing list