Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!udel!princeton!phoenix.Princeton.EDU!subbarao From: subbarao@phoenix.Princeton.EDU (Kartik Subbarao) Newsgroups: comp.unix.questions Subject: Re: grep Keywords: grep, recursive Message-ID: <8304@idunno.Princeton.EDU> Date: 15 Apr 91 19:43:04 GMT References: <1991Apr14.214414.9815@hellgate.utah.edu> Sender: news@idunno.Princeton.EDU Lines: 31 In article <1991Apr14.214414.9815@hellgate.utah.edu> rnelson%hell.utah.edu@cs.utah.edu 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 * > If you know the depth you want to search, you can say: grep pattern */* (i.e matches all files of all subdirectories) you can go as far as you want, i.e grep pattern */*/* Another way is to use find: find . -exec grep pattern "{}" \; or you could use xargs: find . -print | xargs grep pattern. -Kartik -- internet# rm `df | tail +2 | awk '{ printf "%s/quotas\n",$6}'` subbarao@phoenix.Princeton.EDU -| Internet kartik@silvertone.Princeton.EDU (NeXT mail) SUBBARAO@PUCC.BITNET - Bitnet