grep -r isn't working

Hi,

I was trying to use this particular option of grep
grep -r 'Search_pattern' *

This command should ideally search all the occurrences of Search_pattern recursively within a directory & print it on shell prompt. But this command is not doing what is expected. It just displays nothin!

While other commands are working
Ex:grep -n 'Search_pattern' *

Can anyone tell me any other alternative option? Its pretty urgent & am stuck here!!

Try -R. If that does not work, then you will have to see the man pages of grep.

if nothing else work, try the "find" command and pipe the output to "grep"...

Well, even grep -R isn't working!

These are non standard Gnu extensions. You can install Gnu grep if you want them. It may already be installed in /usr/gnu/bin/grep depending on your Solaris release.

using grep -i <pattern> ?

"grep -i" if to ignore search pattern case, nothing related to a recursive search.

More than likely, the -r & -R commands are not valid, check the man pages, as someone suggested earlier.

Try this:

find . -depth -exec grep 'Search_pattern' {} \; -print

This works! :slight_smile: