From owner-freebsd-questions@FreeBSD.ORG Fri Nov 14 00:56:36 2003 Return-Path: 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 65AE716A4CE for ; Fri, 14 Nov 2003 00:56:36 -0800 (PST) Received: from dire.bris.ac.uk (dire.bris.ac.uk [137.222.10.60]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6371243F3F for ; Fri, 14 Nov 2003 00:56:35 -0800 (PST) (envelope-from Jan.Grant@bristol.ac.uk) Received: from mail.ilrt.bris.ac.uk by dire.bris.ac.uk with SMTP-PRIV with ESMTP; Fri, 14 Nov 2003 08:52:38 +0000 Received: from cmjg (helo=localhost) by mail.ilrt.bris.ac.uk with local-esmtp (Exim 3.16 #1) id 1AKZee-0004gg-00; Fri, 14 Nov 2003 08:50:12 +0000 Date: Fri, 14 Nov 2003 08:50:12 +0000 (GMT) From: Jan Grant X-X-Sender: cmjg@mail.ilrt.bris.ac.uk To: Francisco Reyes In-Reply-To: <20031113234031.G85730@zoraida.natserv.net> Message-ID: References: <20031113173505.F84157@zoraida.natserv.net> <20031113223611.X85161@zoraida.natserv.net> <200311141504.57201.jrhoden@unimelb.edu.au> <20031113234031.G85730@zoraida.natserv.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: Jan Grant cc: Matthew Hunt cc: FreeBSD Questions List Subject: Re: Recursion with grep? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 14 Nov 2003 08:56:36 -0000 On Thu, 13 Nov 2003, Francisco Reyes wrote: > On Fri, 14 Nov 2003, JacobRhoden wrote: > > > No need to hack grep plese! just use -R (it appears the man page does not > > document the -R function, but you need to use -R in grep for it to recurse. > > -R == -r > > That was mentioned in the previous emails. It only recurses directories. > It will not work with a filemask. > > You can't say > grep -r *.c > > You can only say > grep -r That's correct, but the Unix Way is* to use small tools that do one job well* and compose them for the desired effect. Someone's already given you an invocation of find and xargs that (almost) does what you want: find . -type f -name \*.c -print0 | xargs -0 grep -h searchstring If you like, wrap this up with a script. Call the script "grep" and stick it closer to the start of your path than the system one. Even the win32 shell is more capable of command composition these days. Chucking as much disparate functionality as possible into each tool is a poor tactic because you wind up with every tool being indistinguishable from its peers, modulo the totally incompatible and irregular interface :-) G'luck, jan * allegedly :-) -- jan grant, ILRT, University of Bristol. http://www.ilrt.bris.ac.uk/ Tel +44(0)117 9287088 Fax +44 (0)117 9287112 http://ioctl.org/jan/ and Nostradamus never dreamed of the Church of the Accellerated Worm