From owner-freebsd-questions Wed Dec 25 6:11:49 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9B56237B401; Wed, 25 Dec 2002 06:11:47 -0800 (PST) Received: from hotmail.com (f25.law15.hotmail.com [64.4.23.25]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4F6E243F1E; Wed, 25 Dec 2002 06:11:47 -0800 (PST) (envelope-from bill_moran2@hotmail.com) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Wed, 25 Dec 2002 06:02:07 -0800 Received: from 66.132.12.15 by lw15fd.law15.hotmail.msn.com with HTTP; Wed, 25 Dec 2002 14:02:07 GMT X-Originating-IP: [66.132.12.15] From: "Bill Moran" To: grog@FreeBSD.org Cc: questions@freebsd.org Subject: Re: Argument list too long: limitation in grep? bash? FreeBSD? Date: Wed, 25 Dec 2002 09:02:07 -0500 Mime-Version: 1.0 Content-Type: text/plain; format=flowed Message-ID: X-OriginalArrivalTime: 25 Dec 2002 14:02:07.0886 (UTC) FILETIME=[363E8AE0:01C2AC1E] Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG >From: Greg 'groggy' Lehey >On Tuesday, 24 December 2002 at 17:25:23 -0500, Bill Moran wrote: > > d/l the entire php documentation as individual html files. > > This equates to a LOT of files in a single directory (how can > > I get a count of this?) > > Anyway, I'm trying to find the docs on some features that > > the www.php.net's search isn't really helping on (searching > > for __FILE__ doesn't search for __FILE__ ... it searches for > > file, and there's too many results) so I try: > > grep __FILE__ *.html > > and I get the error: > > -bash: /usr/bin/grep: Argument list too long > > Is this a shortcoming of bash, grep or FreeBSD? I'm assuming > > it's not grep, as the command: > > find . -name *.html -print | xargs grep __FILE__ > > yeilds: > > -bash: /usr/bin/find: Argument list too long > >Well, it's not a shortcoming. These argument lists get passed into >the kernel by execve(), which changes the process image. There's only >a certain size you can put in. Understood. Perhaps 'shortcoming' wasn't the correct word to use, as it's a designed limitation. It sure feels like a shortcoming when you're just trying to find the page with the docs you need ;) > > I did a little research, and Linux has the MAX_ARG_PAGES kernel > > option to increase the size of the command line arguments it can > > process ... does FreeBSD have such a kernel option, > >Well, we used to have an ARGSMAX variable, but it has now been >replaced by a sysctl kern.argmax. It's set to 65536 by default. You >could increase it, but at some point you'll always run into problems. >You can't make it longer than physical memory, for example. Here we go! This is incredibly useful. It tells me exactly what I need to know. Thanks Greg. > > or some other way of overcoming this limit? > >That's what the xargs program is for. You just used it incorrectly. >It should be: > > find . -name '*.html' -print | xargs grep __FILE__ > >Putting the '' around the name stops the shell from trying to expand >it. Ahhh ... so (making sure to understand this information so I can use it again later) the quotes tell find to expand the pattern, without quotes the shell tries to do it and results in the mentioned error. I used the '' method, as I normally have no need to hunt around in directories this big. But it's good to know that the sysctl is there, in case I ever want to use it. -Bill _________________________________________________________________ MSN 8 with e-mail virus protection service: 3 months FREE*. http://join.msn.com/?page=features/virus&xAPID=42&PS=47575&PI=7324&DI=7474&SU= http://www.hotmail.msn.com/cgi-bin/getmsg&HL=1216hotmailtaglines_eliminateviruses_3mf To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message