From owner-freebsd-questions Thu Dec 27 14:50:58 2001 Delivered-To: freebsd-questions@freebsd.org Received: from smnolde.com (att-98-60-141.atl.mediaone.net [24.98.60.141]) by hub.freebsd.org (Postfix) with ESMTP id 3219A37B631 for ; Thu, 27 Dec 2001 14:50:48 -0800 (PST) Received: from bsd.smnolde.com ([192.168.10.7] helo=bsd ident=smn@smnolde.com) by smnolde.com with esmtp (Exim 3.30 #1) id 16JjMI-000AtN-00; Thu, 27 Dec 2001 17:50:42 -0500 Date: Thu, 27 Dec 2001 17:50:41 -0500 (EST) From: Scott Nolde To: Drew Tomlinson Cc: Subject: Re: How To Recursively Search Directory For Text String In Files? In-Reply-To: <011701c18f24$951d3b00$c42a6ba5@lc.ca.gov> Message-ID: <20011227174915.Q195-100000@bsd.smnolde.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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 smacked into the keyboard previously by owner-freebsd-questions@FreeBSD.ORG: >Date: Thu, 27 Dec 2001 14:19:42 -0800 >From: Drew Tomlinson >To: questions@FreeBSD.ORG >Subject: How To Recursively Search Directory For Text String In Files? > >OK, I am beginning to understand the power of FBSD and am sure this is >possible. I just don't know how to do it. What I want to do is search >all files in my current directory and all the directories below it for a >text string and then know what file(s) contains the string. I >understand that grep will do the search but my knowledge is limited to >"cat file.txt | grep string". How can I construct a command in tcsh to >feed each file to cat and then feed it to grep *AND* know the name of >the file grep found the match? Do I have the right concept? Is there a >better way to accomplish my goal? > >Thanks, > >Drew > > Try this: find . -exec grep -H searchtext {} \; Scott Nolde GPG Key 0xD869AB48 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message