Solved

UNIX grep command question

Posted on 2011-03-08
8
573 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 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
 
LVL 84

Expert Comment

by:ozo
ID: 35078674
find will also find files in subdirectories, unless you restrict it
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

744 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

11 Experts available now in Live!

Get 1:1 Help Now