Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

UNIX grep command question

Posted on 2011-03-08
8
Medium Priority
?
590 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
8 Comments
 
LVL 85

Accepted Solution

by:
ozo earned 1352 total points
ID: 35078397
grep abcd *
0
 
LVL 85

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
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.

 
LVL 85

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 548 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

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

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

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Introduction to Processes
Suggested Courses
Course of the Month12 days, 8 hours left to enroll

972 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