Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
google site



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Display Modes
  #1  
Old 11-13-2001
Registered User
 

Join Date: Jun 2001
Location: India
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Find files containing text

How do I find the files containing some text.

eg. I want to find alll the files that contain the word 'hello'

grep hello * will give me only for the specific directory.

How do I find for entire system.

Thanks for help in advance..
Sponsored Links
  #2  
Old 11-13-2001
LivinFree's Avatar
Goober Extraordinaire
 

Join Date: Jul 2001
Location: Portland, OR, USA
Posts: 1,584
Thanks: 0
Thanked 0 Times in 0 Posts
Wow, for the entire system will take quite some time... but here's one way:
(note: I piped it to a file, in case there's lots of hits. You can view the /tmp/bigsearch.log to see the outputs. Also, you'll get a lot of errors and be very limited in your search if it is not executed by root)

Code:
find / -type f -print | xargs grep "hello" >> /tmp/bigsearch.log 2>/dev/null

Hope that helps...

Also, it may slow your system considerably, depending on the power of your machine. I wouldn't recommend running that on a production or even needed box...
  #3  
Old 11-13-2001
Registered User
 

Join Date: Nov 2001
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
when you use "grep -l" you obtain only names of the propper files ...
  #4  
Old 11-15-2001
Shakey21
Guest
 

Posts: n/a
Bits: 0 [Banking]
Recursive Grep

and another useful way is to try this: grep -il "hello" `find .`


i find that another useful way of doing a recurvsive grep

find . -type f -exec grep -il "hello" {} \;

or if you know the file type

find . -type f -name "*.ext" -exec grep -il "hello" {} \

and/ or if you just want your files

find . -type f -user myname -name "*.ext" -exec grep -il "hello" {} \

and obviously you can still output this to a log file using the redirect >


I hope this helps
  #5  
Old 11-16-2001
guest100's Avatar
Banned
 

Join Date: Oct 2001
Location: London, UK
Posts: 146
Thanks: 0
Thanked 0 Times in 0 Posts
What I suggest is much easier

try :

<pre>

grep whatever /*

</pre>

as simple as that.

That works with solaris !
  #6  
Old 11-16-2001
Jimbo
Guest
 

Posts: n/a
Bits: 0 [Banking]
Easy is not the only objective. Effectivity is more important. I would come down hard on users who attempted to grep my 60 GB of files. Thanks to Shakey for showing the novices how to make their search more effective and less impacting.
Sponsored Links
Closed Thread

Bookmarks

Tags
grep, grep recursive, recursive grep

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
find files where text case is different schipper Shell Programming and Scripting 5 04-26-2006 08:33 AM
How to find a text in jar and zip files.?? redlotus72 UNIX for Dummies Questions & Answers 1 03-07-2006 07:29 AM
To search for a text in until i find that kotasateesh Shell Programming and Scripting 3 08-30-2005 08:32 AM
text files, ASCII files, binary files and ftp transfers Perderabo Answers to Frequently Asked Questions 0 04-08-2004 04:25 PM
grep multiple text files in folder into 1 text file? coppertone UNIX for Dummies Questions & Answers 7 08-23-2002 02:50 PM



All times are GMT -4. The time now is 07:35 AM.