[96456] 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 (Tom Browder)
Tue Oct 27 07:09:06 1998

From: "Tom Browder" <tom2@fwb.asi.srs.com>
To: <redhat-list@redhat.com>
Date: Tue, 27 Oct 1998 06:07:30 -0600
X-MDaemon-Deliver-To: redhat-list@redhat.com
Resent-From: redhat-list@redhat.com
Reply-To: redhat-list@redhat.com

Dave, try this:

  find . -name "<reg expression for file name>" -exec grep "<reg expression to find>" {} \;

The dot says start in the current directory (recursion to subdirectories is automatic).
"grep" and regular expressions may be replaced by fgrep for string literals for faster
searching.  Note carefully the curly braces and the escaped semicolon.  I use
tchsh as my shell and the line works for me.  If you use another shell, mileage may vary.

Good luck.

Tom Browder

-----Original Message-----
From: Dave <DGMDGM@INAME.COM>
To: redhat-list@redhat.com <redhat-list@redhat.com>
Date: Monday, October 26, 1998 5:07 PM
Subject: Newbie: Searching sub directories for text


>Newbie question:
>
>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??
>
>TIA,
>Dave
> 
>
>
>-- 
>  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.
>
>



-- 
  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