Faster Searching !

Jeff Vian jvian10 at charter.net
Mon Feb 7 06:03:01 UTC 2005


On Sun, 2005-02-06 at 22:21 -0600, micheal wrote:
> On Sun, 2005-02-06 at 21:44 -0600, Thomas Cameron wrote:
> > ----- Original Message ----- 
> > From: "fly over" <fly_over at soon.com>
> > To: "Paul Howarth" <paul at city-fan.org>; <fedora-list at redhat.com>
> > Sent: Sunday, February 06, 2005 9:23 PM
> > Subject: Faster Searching !
> > 
> > 
> > > Hi Guruz ,
> > >
> > > I want to ask about the fastest searching command as i am using to search 
> > > SUID/GUID files in / directory . script given as:
> > >
> > >        ls -l /usr/bin | awk '/^-.....[s]/ { print $3, $9 }'
> > >
> > > or using 'find' utility as below
> > >
> > >
> > >        find /usr/bin -perm +6000
> > >
> > >
> > >
> > > now the question is  Which works faster, script without 'find' or with it? 
> > > and How do you know?
> > >
> > > thankx.
> > 
> > Run each command under /usr/bin/time:
> > 
> > /usr/bin/time ls -l /usr/bin | awk '/^-.....[s]/ { print $3, $9 }'
> > 
> > /usr/bin/time find /usr/bin -perm +6000
> > 
> > My bets are on the find command - the ls command relies on a pipe to a 
> > completely different command, which is going to slow the whole process down 
> > a bunch.
> > 
> > Thomas 
> > 
> And for the perpetually curious:
> 
> Find
> 
> real    0m0.025s
> user    0m0.002s
> sys     0m0.019s
> 
and on mine  this was 6% CPU with 183 minor page faults

> ls awk combo
> 
> real    0m0.127s
> user    0m0.092s
> sys     0m0.042s
> 
this was 20% CPU with 518 minor page faults.
(after running find, so the directory data was probably already in
cache)

The clear winner ----->>   find
 





More information about the fedora-list mailing list