• Post Reply Bookmark Topic Watch Topic
  • New Topic

grep  RSS feed

 
Jackie Wang
Ranch Hand
Posts: 315
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to "grep" a string from all the files in the directory with whole bunch of subfolder.
Will grep function support that? If not, any suggestion or sample script?
grep -r doesn't really work
as I am having the error:
ports@colt[220]> grep -r string *
grep: invalid option -- r
Usage: grep [OPTION]... PATTERN [FILE]...
Try `grep --help' for more information.
thanks
 
Loren Rosen
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You must have an old version of grep or something. It would be interesting to see the output of 'grep -V' or 'grep --version'.
Anyway, another way to accomplish what you want is to use the -exec flag to the 'find' program. Something like
find . -exec grep foo {} \;
ought to work.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!