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" {}\;
Related articles
- How to create static binaries (not linked, portable) of GNU find for Solaris 8,9,10 and AIX (stackoverflow.com)
- LINUX Basic Commands (dustycodes.wordpress.com)
- How to Monitor Linux Server (anhtun.wordpress.com)
- Linux hardware details. (amit-agarwal.co.in)