bug-findutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: "find" ends with exit code "0" although exec command returned an err


From: Stephane Chazelas
Subject: Re: "find" ends with exit code "0" although exec command returned an error
Date: Mon, 5 Oct 2015 16:12:51 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

In the case of:

find  ... -exec cmd {} \;

The exit status of cmd is used to determines whether the
predicate evaluates to true or false.

For instance:

find . -exec test -d {} \; -print

Would print the paths of the files that are directories or
symlink to directories, the standard equivalent of the
GNU-specific:

find . -xtype d -print

If you want find to be aborted with a non-zero exit status as
soon as any invocation of cmd fails, you could do:

find . \( -exec cmd {} \; -o -exec sh -c 'kill "$PPID"' \; \)

In the case of:

find ... -exec cmd {} +

The predicate always evaluates to true, but the exit status of
find will be non-zero if any of the invocation of find will
return with a non-zero exit status.

-- 
Stephane




reply via email to

[Prev in Thread] Current Thread [Next in Thread]