Searcg for text string in unix files

I have a task that I have no idea how to do.  I am supposed to search through dozens of directories on our Unix system and find every occurrence of a string in the files.  I need to list the location and name of the files as well.

Any help?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


basically it's

grep -R "string" directory

If you need only filenames, not matching lines it's

grep -lR "string" directory

Please note that the above commands search the subdirectories of "directory" as well, so if the directories you have to search in are all under the same top level directory you'll have to issue the command only once against that top level directory.
Barry62Author Commented:
-R is apparently an illegal option
What is your OS? HPUX?

If so you can try

find directory -type f -print |xargs grep "string" /dev/null

To display just names of files with matches:

find directory -type f -print |xargs grep -l "string"

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Barry62Author Commented:
Yes, it is HPUX.  I will try again Monday morning
Barry62Author Commented:
That worked.  Thanks!  

I added an i to the l option because I needed a non-case sensitive script.  But that got me what I needed.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.