开发者

"find" utility and multiple expressions with/without -a

Is there any difference between

find . ! -name 开发者_高级运维name1 ! -name name2

and

find . ! -name name1 -a ! -name name2

In what cases should I use "-a"?


As the find man page states, all primaries are implicitly "anded", unless you specifically say otherwise. So the two commands are indeed equivalent.

Relevant POSIX quote:

expression [-a] expression

Conjunction of primaries; the AND operator is implied by the
juxtaposition of two primaries or made explicit by the optional -a
operator. The second expression shall not be evaluated if the first
expression is false.

So you never need -a but it may be more readable for larger expressions.


There is no difference. -a ist short for -and, and when you dont give it, its the default (other possible non unary operators are "or" and ",").

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜