Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to use the + option of find exec instead of xargs. However, I can't seem to get it to work. I feel I must be missing something obvious here.

Example:

find . -name "*.java" -exec grep "@author" {} + \;
find: paths must precede expression
Usage: find [-H] [-L] [-P] [path...] [expression]

On the other hand, this works:

find . -name "*.java" -exec grep "@author" {}  \;

as does this:

find . -name "*.java" | xargs  grep "@author"
share|improve this question

2 Answers 2

up vote 3 down vote accepted

You don't need \; together with +

share|improve this answer
1  
find . -name "*.java" -exec grep "@author" {} + –  Dennis Williamson Sep 11 '09 at 8:45

It's much easier just to use find -print0 | xargs --null -I XXX do_something XXX. Let find to the finding and xargs do the, er, other stuff.

share|improve this answer
    
If you use find -print0, you need -0 for xargs. –  Doug Harris Oct 8 '09 at 18:15
    
-0 is the short version of --null. –  Ryan Thompson Oct 8 '09 at 22:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.