toooki
asked on
UNIX grep command question
On a Solaris10 server I am at the directory:
#/usr/mydir/
#
I am looking for files in the directory that has the string "abcd" in the content of the file.
# cat * | grep abcd
The above command gives the lines of those files matching the string. How do I get the actual file names in which the string occurs?
#/usr/mydir/
#
I am looking for files in the directory that has the string "abcd" in the content of the file.
# cat * | grep abcd
The above command gives the lines of those files matching the string. How do I get the actual file names in which the string occurs?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
if you have a lot of files and if you want to ignore case (e.g. file contains Abcd) then tey
find . | xargs grep -i abcd
find . | xargs grep -i abcd
find will also find files in subdirectories, unless you restrict it
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
what you're asking for is the -l (lower case L ) parameter
also, please see the manual pages for grep
use the "man grep" command, or, google "unix man pages" and find several sites on the internet
Tom
also, please see the manual pages for grep
use the "man grep" command, or, google "unix man pages" and find several sites on the internet
Tom
ASKER
Ok thank you all. I could get my work done.
grep -l abcd *