This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: xargs still nok?


> 
> Is Xargs still reqd for
> 
> find . -name '*.cfm' -exec grep -i {} \;

Just because xargs is most often used on the other end of a pipe
from find does not mean that find requires xargs, nor that xargs
requires find.  Both programs also have independent uses.  In
your example above, you are using find to directly do something
(via the -exec action) rather than print a list, so here, xargs won't
help because find isn't even generating a filename list.

By the way, for programs like grep that take more than one file
on the command line, it is much more efficient to pass multiple
files in one go, rather than calling it once per file:

# have find spawn echo once per every file
$ time find . -name '*' -exec echo {} \; >/dev/null

real    0m0.999s
user    0m1.208s
sys     0m0.666s

# have find spit out a list, and xargs spawn echo only once
$ time find . -name '*' |xargs echo >/dev/null

real    0m0.143s
user    0m0.122s
sys     0m0.077s

# let find do the grouping, even faster than xargs!
$ time find . -name '*' -exec echo {} + >/dev/null

real    0m0.094s
user    0m0.076s
sys     0m0.045s

--
Eric Blake
volunteer cygwin findutils maintainer



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]