From owner-freebsd-questions Fri Dec 28 3:25:24 2001 Delivered-To: freebsd-questions@freebsd.org Received: from mobil.cz (diana.mobil.cz [195.39.16.12]) by hub.freebsd.org (Postfix) with ESMTP id 892A137B416 for ; Fri, 28 Dec 2001 03:25:20 -0800 (PST) Received: from ester.mobil.cz (ester.mobil.cz [194.213.62.23]) by mobil.cz (8.11.6/8.11.0) with ESMTP id fBSBPIf14486 for ; Fri, 28 Dec 2001 12:25:19 +0100 Received: from roman.mobil.cz ([10.2.0.89]) by ester.mobil.cz (Lotus Domino Release 5.0.7) with ESMTP id 2001122812234503:3842 ; Fri, 28 Dec 2001 12:23:45 +0100 Received: (from roman@localhost) by roman.mobil.cz (8.11.6/8.11.6) id fBSBY6X06356 for questions@freebsd.org; Fri, 28 Dec 2001 12:34:06 +0100 (CET) (envelope-from neuhauser@mobil.cz) X-Authentication-Warning: roman.mobil.cz: roman set sender to neuhauser@mobil.cz using -f Date: Fri, 28 Dec 2001 12:34:06 +0100 From: Roman Neuhauser To: questions@freebsd.org Subject: Re: How To Recursively Search Directory For Text String In Files? Message-ID: <20011228123405.M476@roman.mobil.cz> Mail-Followup-To: questions@freebsd.org References: <011701c18f24$951d3b00$c42a6ba5@lc.ca.gov> Mime-Version: 1.0 In-Reply-To: <011701c18f24$951d3b00$c42a6ba5@lc.ca.gov> User-Agent: Mutt/1.3.23i X-MIMETrack: Itemize by SMTP Server on ester/Mobil(Release 5.0.7 |March 21, 2001) at 12/28/2001 12:23:45 PM, Serialize by Router on ester/Mobil(Release 5.0.7 |March 21, 2001) at 12/28/2001 12:23:51 PM, Serialize complete at 12/28/2001 12:23:51 PM Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 > From: "Drew Tomlinson" > To: > Subject: How To Recursively Search Directory For Text String In Files? > Date: Thu, 27 Dec 2001 14:19:42 -0800 > > 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? Hi there, the other suggestions are insanely complicated IMO. All you need is > grep -FIHnir pattern path ^^^^^^- recursive search ||||'-- case insensitive search |||'--- report the line number ||'---- report the file name |'----- ignore binary files '------ the pattern is a fixed string > grep -FIHnir freebsd ~/Mail -- FreeBSD 4.4-STABLE 12:27PM up 1 day, 23:05, 9 users, load averages: 0.01, 0.00, 0.00 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message