Force exit status if file not found

Mikkel mikkel at infinity-ltd.com
Mon Mar 7 22:42:36 UTC 2011


On 03/07/2011 04:08 PM, Sergio Belkin wrote:
> Hi,
> I am writing a script that it searchs for a file. I'd want to exit
> with status non-zero if the file is not found. But find cannot do
> that.
> find command only exit with status non-zero one file is not processed
> successfully.
> 
> locate command con do that, but it cannot find a file from a given directory.
> 
> How can I do it?
> 
> Thanks in advance!
You may want to look at the test command. (man test) It is often
used in conjunction with the if command. You can also look at Bash's
built in [ command.

Mikkel
-- 

  Do not meddle in the affairs of dragons,
for thou art crunchy and taste good with Ketchup!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: OpenPGP digital signature
Url : http://lists.fedoraproject.org/pipermail/users/attachments/20110307/3c16c9f4/attachment-0001.bin 


More information about the users mailing list