Skip to content
 

Rekursive Grep on Solaris or AIX Systems without GNU egrep -r funcionality

If you work regularly on a Solaris or systems which do not have the “-r” (recursive grep) for grep, then you know what a lifesaver this command can be.

Here is one from command line fu:

find . -type f -exec awk '/linux/ { printf "%s %s: %s\n", FILENAME, NR, $0; }' {} \;

The benefit of using awk here is that you can print the line number also :)

There are other versions that you can use:

find . -type f -exec grep "string here" {}\;

Some prefer with xargs:

find . -type f |xargs -n 1 grep "string here" {}\;
Enhanced by Zemanta
Sphere: Related Content

Technorati Tags: awk, Command-line interface, grep, Linux, Operating Systems, regular expression, Solaris, Unix