Recursive search doesn't work for grep on solaris

If you want to use find, this would be the fastest way:

find . -type f -exec grep pattern {} +

However, Gnu grep is very likely already installed on your machine.

It is part of the default installation on Solaris 11 in /usr/gnu/bin/grep. Same for Solaris 10 where you find it in /usr/sfw/bin/ggrep. On older releases, it might have been installed from sunfreeware or other repositories, check /usr/local/bin/grep and /opt/csw/bin/grep for common locations.


Use ggrep instead if it is installed.

E.g. Search for "mysearchstring" from the current directory down to all subdirectories (-R), and show the file name and path for matches (-H) and ignore binary files (-I). Don't forget the * on the end of the command.

/usr/sfw/bin/ggrep -H -R -I "mysearchstring" *

ggrep is located in /usr/sfw/bin You can add it to your profile with an EXPORT command so you can call it from the command line directly.

PATH=$PATH:/usr/sfw/bin
export PATH

Solaris version: SunOS 5.10 Generic_147440-13 sun4u sparc SUNW,SPARC-Enterprise


I'm not familiar with Solaris, but if you're switching from GNU/linux to Solaris you'll find most of the commands will behave slightly different. The GNU version of Unix tools have additional features missing in "proprietary" Unixes.

You can download GNU grep(s) here then compile and install.

If you do have root access you might want to run configure --prefix=/usr/local Such that the utilities install into /usr/local

If you do not have root access you might want to run configure --prefix=${HOME} Such that the utilities install into your home directory