Friday, September 28, 2007

Tip for the day: Recursive GREP on Solaris

Linux shells provide a recursive Grep function in the form of the -r switch.

Irritatingly, Solaris is supposed to be more advance but this same function in Solaris will have to be replicated using the piped command as follows:

/usr/bin/find . | /usr/bin/xargs /usr/bin/grep ‘Your Grep Value’

Or if your shell has all the right paths set, simply:

find . | xargs grep ‘Your Grep Value’

5 comments:

smilingrunner said...

Thanks for your post Ive been looking for this! you save lots of my time!

Greg C said...

Only problem I have is that on large directories, I get a lot of extraneous error messages on the directories that grep attempts to search.

Dave said...

/usr/bin/find .|/usr/bin/xargs /usr/bin/grep -s SearchString will suppress error messages

afraoucene said...

This will search in the result of find command which is the current directory files's Paths and not in their contents, so the correct command is :

find . -exec grep -i "SearchString" {} \;

bumbu pecel bali said...

this is good post.
and you can go here

http://bantalsilikon01.blogspot.com
http://kursusinternetmarketingmurah.blogspot.com
http://bumbupecelbali.blogspot.com


tanks very much.... :)