Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Message-ID: <0dde01c21d05$d11a7810$6132bc3e@BABEL>
From: "Conrad Scott" <Conrad.Scott@dsl.pipex.com>
To: "Thomas Baker" <thomas.baker@bi.fhg.de>
Cc: <cygwin@cygwin.com>
References: <20020626125840.A576@mail.gmd.de>
Subject: Re: grep - limited number of arguments?
Date: Wed, 26 Jun 2002 12:37:10 +0100
MIME-Version: 1.0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000

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

