From owner-freebsd-questions Tue Dec 23 07:26:54 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id HAA13537 for questions-outgoing; Tue, 23 Dec 1997 07:26:54 -0800 (PST) (envelope-from owner-freebsd-questions) Received: from awfulhak.demon.co.uk (awfulhak.demon.co.uk [158.152.17.1]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id HAA13516 for ; Tue, 23 Dec 1997 07:26:35 -0800 (PST) (envelope-from brian@awfulhak.org) Received: from gate.lan.awfulhak.org (localhost [127.0.0.1]) by awfulhak.demon.co.uk (8.8.7/8.8.7) with ESMTP id PAA10788; Tue, 23 Dec 1997 15:09:55 GMT (envelope-from brian@gate.lan.awfulhak.org) Message-Id: <199712231509.PAA10788@awfulhak.demon.co.uk> X-Mailer: exmh version 2.0zeta 7/24/97 To: joelh@gnu.org cc: freebsd-questions@freebsd.org Subject: Re: using the find command In-reply-to: Your message of "Sun, 21 Dec 1997 23:07:51 CST." <199712220507.XAA05231@detlev.UUCP> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Tue, 23 Dec 1997 15:09:55 +0000 From: Brian Somers Sender: owner-freebsd-questions@freebsd.org X-Loop: FreeBSD.org Precedence: bulk > (Apologies to threaders) > > >> Can somebody give me the syntax for using the find command to search > >> all the files in a tree for a specific string? > > find . -name "*" -exec grep -l string {} \; > > This is less efficient than > grep string `find . -print` Hmm, this isn't very good at all if you've got a large number of files under `.'. The best way(s) to do it is either find . | xargs grep string or as someone else pointed out, grep -R string . > > Also note that '-name *' is redundant in find. > > Cheers, > joelh > > -- > Joel Ray Holveck - joelh@gnu.org - http://www.wp.com/piquan > Fourth law of programming: > Anything that can go wrong wi > sendmail: segmentation violation - core dumped -- Brian , , Don't _EVER_ lose your sense of humour....