delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/09/08/10:50:56

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
From: ericblake AT comcast DOT net (Eric Blake)
To: zzapper <david AT tvis DOT co DOT uk>, cygwin AT cygwin DOT com
Subject: Re: xargs still nok?
Date: Thu, 08 Sep 2005 14:50:38 +0000
Message-Id: <090820051450.28740.43204FBE00096E3A0000704422073007930A050E040D0C079D0A@comcast.net>
X-Authenticated-Sender: ZXJpY2JsYWtlQGNvbWNhc3QubmV0

> 
> 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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019