UNIX grep command question

Posted on 2011-03-08
Last Modified: 2012-05-11
On a Solaris10 server I am at the directory:


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?
Question by:toooki
LVL 84

Accepted Solution

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

Expert Comment

ID: 35078412
grep -l abcd *
LVL 40

Expert Comment

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
LVL 84

Expert Comment

ID: 35078674
find will also find files in subdirectories, unless you restrict it
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

LVL 12

Assisted Solution

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

Expert Comment

ID: 35081375

Expert Comment

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


Author Comment

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
groupSum6 challenge 6 76
linux ssh 4 57
CentOS/RHEL 7 Linux maillog worldwide readable 2 39
Shell Script on AIX 7 61
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
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 …

947 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now