Barry62
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?
Any help?
ASKER
-R is apparently an illegal option
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes, it is HPUX. I will try again Monday morning
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.
I added an i to the l option because I needed a non-case sensitive script. But that got me what I needed.
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.