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

2011-12-16 135 words 1 min read

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

author

Authored By Amit Agarwal

Amit Agarwal, Linux and Photography are my hobbies.Creative Commons Attribution 4.0 International License.

We notice you're using an adblocker. If you like our webite please keep us running by whitelisting this site in your ad blocker. We’re serving quality, related ads only. Thank you!

I've whitelisted your website.

Not now
This website uses cookies to ensure you get the best experience on our website. Learn more Got it