Register | Login


In order to recursively search a string or pattern in Linux we can use '-r' option.

grep -lre “Error” /opt/*

-r will recursively search all the files and folder under the specified location.


AIX or Solaris or Unix:

AIX or Solaris or Unix version of grep command does not have the sophisticated '-r' option.

But we can achieve the same using the below command.

find . -name "/opt/*" -exec grep -l Error {} ;

find command will search for all the files under /opt directory. This output will be passed to grep command and grep will search for the 'Error' pattern or string in those files. Hence we will get the similar output.

This is the equivalent of '-r' Linux option.

-l will display only the name of the file.

* specifies any type of files

Who Voted for this Article, is a website that will allow everyone to share their knowledge, tip or information through community micro blogging.