Solved

UNIX grep command question

Posted on 2011-03-08
8
582 Views
Last Modified: 2012-05-11
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
Comment
Question by:toooki
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 338 total points
ID: 35078397
grep abcd *
0
 
LVL 84

Expert Comment

by:ozo
ID: 35078412
or
grep -l abcd *
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 35078448
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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 84

Expert Comment

by:ozo
ID: 35078674
find will also find files in subdirectories, unless you restrict it
0
 
LVL 12

Assisted Solution

by:upanwar
upanwar earned 137 total points
ID: 35081364
Here you will find lots of example for your need.

http://www.cyberciti.biz/faq/howto-use-grep-command-in-linux-unix/
0
 
LVL 12

Expert Comment

by:upanwar
ID: 35081375
0
 
LVL 6

Expert Comment

by:Tomunique
ID: 35082736
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
 

Author Comment

by:toooki
ID: 35087828
Ok thank you all. I could get my work done.
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question