From owner-freebsd-questions Tue Dec 24 15:24:23 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 4B52C37B401 for ; Tue, 24 Dec 2002 15:24:21 -0800 (PST) Received: from wantadilla.lemis.com (wantadilla.lemis.com [192.109.197.80]) by mx1.FreeBSD.org (Postfix) with ESMTP id AEB4F43EB2 for ; Tue, 24 Dec 2002 15:24:19 -0800 (PST) (envelope-from grog@lemis.com) Received: by wantadilla.lemis.com (Postfix, from userid 1004) id 74F1C5194A; Wed, 25 Dec 2002 09:54:17 +1030 (CST) Date: Wed, 25 Dec 2002 09:54:17 +1030 From: Greg 'groggy' Lehey To: Bill Moran Cc: questions@freebsd.org Subject: Re: Argument list too long: limitation in grep? bash? FreeBSD? Message-ID: <20021224232417.GI79700@wantadilla.lemis.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4i Organization: The FreeBSD Project Phone: +61-8-8388-8286 Fax: +61-8-8388-8725 Mobile: +61-418-838-708 WWW-Home-Page: http://www.FreeBSD.org/ X-PGP-Fingerprint: 9A1B 8202 BCCE B846 F92F 09AC 22E6 F290 507A 4223 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 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. > 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. > 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. Greg -- When replying to this message, please copy the original recipients. If you don't, I may ignore the reply or reply to the original recipients. For more information, see http://www.lemis.com/questions.html See complete headers for address and phone numbers To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message