[nSLUG] /usr/bin/find 'found'/'not found' exit codes?

Luke Gavel fidomail2002 at yahoo.ca
Fri May 9 22:15:44 ADT 2008


I suppose, if CPU cycles were 'expensive', -n might shave off some extra cycles rather than piping it to the grep's exit code.  Other than that, I don't see any real difference, if there really is one.  There likely isn't any difference because you're still having to pass it to the bash 'test' system:

[lgavel at d114-001 local]$ time [ -n "`find / -name traceroute -print 2> /dev/null`" ] && echo "Found it" || echo "it ain't there, Dave"

real    1m48.493s
user    0m0.443s
sys     0m1.997s
Found it
[lgavel at d114-001 local]$ time [ -n "`find / -name traceroute -print 2> /dev/null`" ] && echo "Found it" || echo "it ain't there, Dave"

real    1m18.710s
user    0m0.406s
sys     0m1.801s
Found it
[lgavel at d114-001 local]$ time find / -name traceroute -print 2> /dev/null | grep "traceroute" &> /dev/null && echo "Found it" || echo "it ain't there, Dave"

real    1m19.495s
user    0m0.464s
sys     0m1.772s
Found it
[lgavel at d114-001 local]$ time find / -name traceroute -print 2> /dev/null | grep "traceroute" &> /dev/null && echo "Found it" || echo "it ain't there, Dave"

real    1m33.082s
user    0m0.419s
sys     0m1.959s
Found it

--- On Fri, 5/2/08, Daniel Morrison <draker at gmail.com> wrote:

> From: Daniel Morrison <draker at gmail.com>
> Subject: Re: [nSLUG] /usr/bin/find 'found'/'not found' exit codes?
> To: "Nova Scotia Linux User Group" <nslug at nslug.ns.ca>
> Received: Friday, May 2, 2008, 1:02 AM
> 2008/5/2 Daniel Morrison <draker at gmail.com>:
> 
> Sorry, wrapped these lines by mistake, without escaping the
> new line.
> 
> -D.
> 
> user$ [ -n "`find /usr/bin -name find -print`" ]
> && echo found find \
>   ||  echo didn\'t find find
> found find
> 
> user$ [ -n "`find /usr/bin -name found -print`" ]
> && echo found found \
>   || echo didn\'t find found
> didn't find found
> _______________________________________________
> nSLUG mailing list
> nSLUG at nslug.ns.ca
> http://nslug.ns.ca/cgi-bin/mailman/listinfo/nslug


      __________________________________________________________________
Be smarter than spam. See how smart SpamGuard is at giving junk email the boot with the All-new Yahoo! Mail.  Click on Options in Mail and switch to New Mail today or register for free at http://mail.yahoo.ca



More information about the nSLUG mailing list