From owner-freebsd-fs@FreeBSD.ORG Fri Mar 8 19:09:25 2013 Return-Path: Delivered-To: freebsd-fs@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 5A03DB2B for ; Fri, 8 Mar 2013 19:09:25 +0000 (UTC) (envelope-from brooks@lor.one-eyed-alien.net) Received: from lor.one-eyed-alien.net (lor.one-eyed-alien.net [69.66.77.232]) by mx1.freebsd.org (Postfix) with ESMTP id 93E695E6 for ; Fri, 8 Mar 2013 19:09:24 +0000 (UTC) Received: from lor.one-eyed-alien.net (localhost [127.0.0.1]) by lor.one-eyed-alien.net (8.14.5/8.14.5) with ESMTP id r28J9IhY036146; Fri, 8 Mar 2013 13:09:18 -0600 (CST) (envelope-from brooks@lor.one-eyed-alien.net) Received: (from brooks@localhost) by lor.one-eyed-alien.net (8.14.5/8.14.5/Submit) id r28J9HXT036145; Fri, 8 Mar 2013 13:09:17 -0600 (CST) (envelope-from brooks) Date: Fri, 8 Mar 2013 13:09:17 -0600 From: Brooks Davis To: Lars Engels Subject: Re: Argument list too long Message-ID: <20130308190917.GA34838@lor.one-eyed-alien.net> References: <82112.1362671436.13776555968178880512@ffe17.ukr.net> <20130307161546.GV47829@e-new.0x20.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="WIyZ46R2i8wDzkSu" Content-Disposition: inline In-Reply-To: <20130307161546.GV47829@e-new.0x20.net> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: freebsd-fs@freebsd.org X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Mar 2013 19:09:25 -0000 --WIyZ46R2i8wDzkSu Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Mar 07, 2013 at 05:15:46PM +0100, Lars Engels wrote: > On Thu, Mar 07, 2013 at 05:50:36PM +0200, Vladislav Prodan wrote: > > Why 12K small files from one directory to cause problems? > >=20 > > # ll | wc -l > > 11467 > >=20 > > # grep X-PHP-Script * | more > > /sbin/grep: Argument list too long. > >=20 > > # egrep X-PHP-Script *.ua | more > > /usr/sbin/egrep: Argument list too long. > >=20 > > # cat *.ua | grep X-PHP-Script | more > > /sbin/cat: Argument list too long. > >=20 > >=20 > >=20 >=20 > Your shell can't process that many arguments. Use this: >=20 > grep -R "X-PHP-Script" . >=20 > or if you don't want to descent into subdirectories: >=20 > find . -type -f -name '*.ua' -maxdepth 1 -exec grep "X-PHP-Script" {} \+ This won't include file names and is gratuitously inefficient starting one grep per file. The command you're looking for is: find . -type -f -name '*.ua' -maxdepth 1 -print0 | xargs -0 grep -H "X-PHP-= Script" The find -print0 | xargs -0 allows filenames to contain spaces. The grep -H is mostly theoretical in that the last grep invocation by xargs couple only include one file and thus wouldn't include the filename. -- Brooks --WIyZ46R2i8wDzkSu Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iD8DBQFROjdcXY6L6fI4GtQRAmEDAKCtwDnf44zqZ/GMFR7WnbupmqsK/gCfYY8O Jj0AsMtFo0inkCqLURQVBT4= =zhxl -----END PGP SIGNATURE----- --WIyZ46R2i8wDzkSu--