|
google site
|
|||||||
| Forums | Register | Blog | Man Pages | Forum Rules | Links | Albums | FAQ | Users | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 !! |
![]() |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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
|
||||
|
||||
|
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
|
|||
|
|||
|
when you use "grep -l" you obtain only names of the propper files ...
|
|
#4
|
|||
|
|||
|
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
|
||||
|
||||
|
What I suggest is much easier
try : <pre> grep whatever /* </pre> as simple as that. That works with solaris ! |
|
#6
|
|||
|
|||
|
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 | ||
|
|
![]() |
| Bookmarks |
| Tags |
| grep, grep recursive, recursive grep |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
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 |