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

Luke Gavel fidomail2002 at yahoo.ca
Fri May 2 01:33:50 ADT 2008


Are there any plans to modify the 'find' code to return another exit code or change the current meaning of the exit code?  Right now, the find command only exits with error code #1 if it detects a syntax error.  You have to pipe it through grep to get a #0 'found' or #1 'not found' exit code.  Why can't the find command do that itself?

find /usr/bin -iname 'find' && echo "You did me right" || echo "You did me wrong"
/usr/bin/find
You did me right


find /usr/bin -iname 'baboo' && echo "You did me right" || echo "You did me wrong"
You did me right

find /usr/bin -huhwhat 'baboo' && echo "You did me right" || echo "You did me wrong"      find: invalid predicate `-huhwhat'
You did me wrong

 find /usr/bin -iname 'find' | grep 'find' && echo "I found it" || echo "I didn't find it" /usr/bin/find
I found it

 find /usr/bin -iname 'baboo' | grep 'baboo' && echo "I found it" || echo "I didn't find it"
I didn't find it

--Luke G.


      __________________________________________________________________
Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your favourite sites. Download it now at
http://ca.toolbar.yahoo.com.



More information about the nSLUG mailing list