Find in file. Does this exist under UNIX? | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


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

Find in file. Does this exist under UNIX?

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 01-19-2006
scampsd scampsd is offline
Registered User
 
Join Date: Dec 2005
Last Activity: 24 April 2012, 8:07 AM EDT
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Question Find in file. Does this exist under UNIX?

Hello,
I have the following problem. I know there is a file somewhere on a UNIX machine that contains a string, but I don't know where.
With the "grep" command, I can look into a file but only if I'm located in the correct directory.
With the "find" command, I can search across directories but I cannot specify to search within the files for a certain string.

Does there exist a standard UNIX command for looking for a text within a file without knowing the directory in which the file is located?

Thanks
Dominique
Sponsored Links
    #2  
Old 01-19-2006
mahendramahendr mahendramahendr is offline Forum Advisor  
Registered User
 
Join Date: Dec 2005
Last Activity: 22 August 2008, 8:28 AM EDT
Location: London
Posts: 222
Thanks: 0
Thanked 0 Times in 0 Posts
find . -name "*" -exec grep -l "somestring" {} \;

or

find . -name "*" | xargs grep -l "somestring"

change grep options according to your need
Sponsored Links
    #3  
Old 01-19-2006
scampsd scampsd is offline
Registered User
 
Join Date: Dec 2005
Last Activity: 24 April 2012, 8:07 AM EDT
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
MySQL Thanks

I have tried. It works fine.

Thank you
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Find out whether files exist. kevintse Shell Programming and Scripting 3 06-11-2010 03:19 AM
How to find if file exist in directory using * buj UNIX for Dummies Questions & Answers 2 01-01-2010 05:32 AM
Can I find wether a particular file exist and size greater than zero...help please guhas Shell Programming and Scripting 4 11-28-2005 12:56 PM
Does UNIX-Chmod in windows exist? izy100 UNIX for Advanced & Expert Users 2 09-21-2005 04:51 AM
how to find a file in UNIX without find command? bluo Shell Programming and Scripting 3 09-24-2003 11:47 PM



All times are GMT -4. The time now is 05:08 PM.