grep

Sundaraswaran Gopalakrishnan sundrag at risky.Convergent.COM
Tue Apr 16 05:18:24 AEST 1991


In article <1991Apr14.214414.9815 at hellgate.utah.edu>, mmoore%hellgate.utah.edu at cs.utah.edu (Michael Moore) writes:
> 
> 	
> 	Does anyone know if there is an easy way to recursively search for a 
> pattern down the entire file tree of a directory?  
> 	I have tried :  grep -R pattern *
> 			grep -r pattern *
> 			grep -R pattern dirname
> 			grep -r pattern dirname
> 			
> 
> 	I don't know what to do.  If there were a way to recursively cat 
> files or something similar, I could pipe that to grep, but I can't find that
> either.
> 
> 	ANY help would be greatly appreciated.
> 
> 	(P.S.  Is this the proper newsgroup to post this question to?)
> 	(      If not, please let me know which one is.              )
> 
> 
> 
> Michael Moore
> University of Utah
> 
> <><><><><><><>><><><><><><><><><><><><><><>
> <>He spoke seldom, ate little, slept less<>
> <> 	-Ursula K. LeGuin	         <>
> <>	 *Wizard of Earthsea*            <>
> <><><><<><><><><><><><><><><><><><><><><><>

You can do the following :
find / -print | xargs grep <pattern>
or,
find / -name "*.c" -print | xargs grep <pattern>

xargs constructs the argument list from its input and 'll
apply grep to each argument ( which is different from just 
"find / -print | grep <pattern>", which 'll look for a *file*
that matches <pattern> )

Sundar, Unisys



More information about the Comp.unix.questions mailing list