From owner-freebsd-current@FreeBSD.ORG Fri Sep 24 00:03:18 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0EA7F16A4CE for ; Fri, 24 Sep 2004 00:03:18 +0000 (GMT) Received: from aiolos.otenet.gr (aiolos.otenet.gr [195.170.0.23]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5EAC943D45 for ; Fri, 24 Sep 2004 00:03:16 +0000 (GMT) (envelope-from keramida@linux.gr) Received: from gothmog.gr (patr530-a179.otenet.gr [212.205.215.179]) i8O03EYV025138; Fri, 24 Sep 2004 03:03:14 +0300 Received: from gothmog.gr (gothmog [127.0.0.1]) by gothmog.gr (8.13.1/8.13.1) with ESMTP id i8O03E8l027607; Fri, 24 Sep 2004 03:03:14 +0300 (EEST) (envelope-from keramida@linux.gr) Received: (from giorgos@localhost) by gothmog.gr (8.13.1/8.13.1/Submit) id i8O03DEn027606; Fri, 24 Sep 2004 03:03:13 +0300 (EEST) (envelope-from keramida@linux.gr) Date: Fri, 24 Sep 2004 03:03:13 +0300 From: Giorgos Keramidas To: Juha Saarinen Message-ID: <20040924000313.GB27322@gothmog.gr> References: <009301c4a173$d468de90$7890a8c0@gits.invalid> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Phone: +30-2610-312145 Mobile: +30-6944-116520 cc: freebsd-current@freebsd.org Subject: Re: Could ARG_MAX be increased? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Sep 2004 00:03:18 -0000 On 2004-09-24 07:33, Juha Saarinen wrote: > > You can use the -exec feature of 'find' other wise - > > find . -type f -exec grep "something" {} /dev/null \; > > -- the /dev/null is, according to a friend, "to provide grep with more > than one input file, so that includes the file name in any matches. The friend is correct. This is a nice trick. xargs will construct a command line by appending one or more filenames to what you pass. The important part being ``one or more''. If xargs appends one filename to an argument list of `grep foo', the executed command is `grep foo filename', which will not list the name of the file with every match since grep sees only 1 filename argument. If the argument list passed to xargs is `grep foo /dev/null' though, the executed command is `grep foo /dev/null filename'; in this case the filenames grep sees are always at least 2, which enables printing the filename with every match. This is better illustrated with an example: $ grep PS1 .bashrc export PS1='${USER}@\h[\A]${PWD}\$ ' $ grep PS1 /dev/null .bashrc .bashrc:export PS1='${USER}@\h[\A]${PWD}\$ ' Regards, Giorgos