This is the mail archive of the
cygwin@cygwin.com
mailing list for the Cygwin project.
Re: grep - limited number of arguments?
- From: "Conrad Scott" <Conrad dot Scott at dsl dot pipex dot com>
- To: "Thomas Baker" <thomas dot baker at bi dot fhg dot de>
- Cc: <cygwin at cygwin dot com>
- Date: Wed, 26 Jun 2002 12:37:10 +0100
- Subject: Re: grep - limited number of arguments?
- References: <20020626125840.A576@mail.gmd.de>
"Thomas Baker" <thomas.baker@bi.fhg.de> wrote:
> One difficulty I have found, however, is limitations (or so
> it would seem) on the number of arguments that the command
> "grep" can take.
You can't (portably) rely on anything much more than a few thousand
characters in a single command line. The minimum requirement for a
Posix system is 4096 (see <limits.h>). The usual technique is to use
`xargs', as:
ls | xargs grep pattern
(or even `ls | xargs grep pattern /dev/null' to catch the case with
only one argument being given to grep and it changing behaviour).
This splits up the incoming arguments and invokes grep repeatedly, a
batch of the arguments at a time. It's particularly useful with `find'
and it's got lots of lovely options to play with too :-)
It would be nice to allow arbitrary command lines, but I've never
(knowingly) used a system that did so.
// Conrad
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/