• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 591
  • Last Modified:

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?
0
toooki
Asked:
toooki
2 Solutions
 
ozoCommented:
grep abcd *
0
 
ozoCommented:
or
grep -l abcd *
0
 
omarfaridCommented:
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
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
ozoCommented:
find will also find files in subdirectories, unless you restrict it
0
 
upanwarCommented:
Here you will find lots of example for your need.

http://www.cyberciti.biz/faq/howto-use-grep-command-in-linux-unix/
0
 
TomuniqueCommented:
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
0
 
toookiAuthor Commented:
Ok thank you all. I could get my work done.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now