The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
PERL: Searching for a string in a text file problem meevagh Shell Programming and Scripting 15 05-01-2008 10:57 AM
Searching for text in a Space delimited File andyblaylock UNIX for Dummies Questions & Answers 6 11-27-2007 07:33 PM
searching each file in a directory for text jim majors Shell Programming and Scripting 2 03-23-2006 08:29 PM
Help with searching a text file thekid2 Shell Programming and Scripting 6 01-02-2004 02:09 AM
Searching a file withoug leaving home directory!! abidmalik UNIX for Dummies Questions & Answers 2 09-05-2002 05:04 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-03-2006
LordJezo
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
Searching directory for file that contains some text.

If I go into a directory and type in ..

more * | grep foo

I get the lines of text that contain foo in all of the files in the directory out of all of the files that are there.

How do I make it so I can find out what the names of the files are that contain that text "foo"? By doing what I typed in all I do is get a whole bunch of lines of text but not the extra file names, I know the file I need is in the directory I am in but I don't know what file it is.

Any advice? Thanks.
  #2 (permalink)  
Old 04-03-2006
ashterix ashterix is offline
Registered User
  
 

Join Date: Nov 2005
Location: cyberjaya
Posts: 85
is this what u looking for?

$ grep -l foo *
  #3 (permalink)  
Old 04-04-2006
reddymails reddymails is offline
Registered User
  
 

Join Date: Feb 2006
Posts: 25
hi,
If u want to serach in all sub directories recursively try this.
for i in ` find . -name "*" -print`
do
grep -l foo ${i}
done


This will list all files that have the keyword foo.
  #4 (permalink)  
Old 04-04-2006
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
Code:
find /dir/to/be/searched -name '*.*' -exec grep 'search string' {} /dev/null \;
  #5 (permalink)  
Old 04-04-2006
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,717
I think he just wants to find the name of the file...

Code:
find /dir/to/be/searched -name '*.*' -exec grep -l 'search string' {} \;
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:29 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0