[96379] in RedHat Linux List

home help back first fref pref prev next nref lref last post

Re: Newbie: Searching sub directories for text

daemon@ATHENA.MIT.EDU (lconrad@world.std.com)
Mon Oct 26 18:29:47 1998

From: lconrad@world.std.com
To: redhat-list@redhat.com
Date: 26 Oct 1998 18:27:59 -0500
In-Reply-To: Dave's message of "Mon, 26 Oct 1998 18:10:13 -0500"
Resent-From: redhat-list@redhat.com
Reply-To: redhat-list@redhat.com

--Multipart_Mon_Oct_26_18:27:59_1998-1
Content-Type: text/plain; charset=US-ASCII

Dave <DGMDGM@INAME.COM> writes:

> How can I search a directory and all of its sub directories for a file
> containing a specified text string. I know how to use grep to search a
> single directory but is there a way to make it search all of the sub
> directories too? Maybe there is another program that I should be using??

Try:

	find <directory> -type f -print | xargs grep <string>

It's worth learning to use find if you want to do operations on a
whole directory tree.  There is a syntax for executing a command like
grep directly on the find command line, but I find the pipe to xargs
easier to remember and type.

--Multipart_Mon_Oct_26_18:27:59_1998-1
Content-Type: text/plain; charset=US-ASCII

Laura (lconrad@world.std.com, http://www.world.std.com/~lconrad/ )
(617) 661-8097	 
233 Broadway, Cambridge, MA 02139

--Multipart_Mon_Oct_26_18:27:59_1998-1--


-- 
  PLEASE read the Red Hat FAQ, Tips, Errata and the MAILING LIST ARCHIVES!
		http://www.redhat.com http://archive.redhat.com
         To unsubscribe: mail redhat-list-request@redhat.com with 
                       "unsubscribe" as the Subject.


home help back first fref pref prev next nref lref last post