Link to home
Start Free TrialLog in
Avatar of Barry62
Barry62Flag for United States of America

asked on

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?
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Hi,

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.
Avatar of Barry62

ASKER

-R is apparently an illegal option
ASKER CERTIFIED SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Barry62

ASKER

Yes, it is HPUX.  I will try again Monday morning
Avatar of Barry62

ASKER

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.