Solved

UNIX grep command question

Posted on 2011-03-08
8
579 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Ubuntu not booting - How get past GRUB? 3 43
Linux VM 6 88
How yum repo uses sqlite3 to keep metadata about the repository? 2 34
bash file 10 37
A short article about a problem I had getting the GPS LocationListener working.
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
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 …

773 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