rgrep equivallent on Solaris

There is no recursive grep function on Solaris. The work around that we use at work is,

find ./ -name *.java | xargs grep “mystring”

Suppose you want to find all Java class files under a given directory, including the sub directories, that use the resource bundle key “prop.file.path”

First part of the command returns all the files with .java extension -
find ./ -name *.java

The output of find command is given as input to the grep command using pipe symbol. xargs (http://en.wikipedia.org/wiki/Xargs) is used to split the large number of results returned by find command and pass it one by one to grep.

find ./ -name *.java   | xargs grep “prop.file.path”

1 Comment »

  1. DaleB said

    Please explain the abaove command in detail

RSS feed for comments on this post · TrackBack URI

Leave a Comment