# Find files containing text

**URL:** <https://community.unix.com/t/find-files-containing-text/140295>\
**Category:** UNIX for Dummies Questions & Answers\
**Created:** [November 13, 2001, 5:11am UTC](https://community.unix.com/t/find-files-containing-text/140295 "2001-11-13T05:11:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sushrut](https://community.unix.com/letter_avatar/sushrut/32/5_5575768a8748004e209b776fc1b2916d.png) [@sushrut](https://community.unix.com/u/sushrut)\
**Post date:** [November 13, 2001, 5:11am UTC](https://community.unix.com/t/find-files-containing-text/140295/1 "2001-11-13T05:11:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![LivinFree](https://community.unix.com/user_avatar/community.unix.com/livinfree/32/20_2.png) [@LivinFree](https://community.unix.com/u/LivinFree)\
**Post date:** [November 13, 2001, 7:28am UTC](https://community.unix.com/t/find-files-containing-text/140295/2 "2001-11-13T07:28:30Z")

</div>

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)

```nohighlight
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...

---

<div class="post-metadata">

**Author:** ![Rado1x](https://community.unix.com/letter_avatar/rado1x/32/5_5575768a8748004e209b776fc1b2916d.png) [@Rado1x](https://community.unix.com/u/Rado1x)\
**Post date:** [November 13, 2001, 9:55am UTC](https://community.unix.com/t/find-files-containing-text/140295/3 "2001-11-13T09:55:02Z")

</div>

when you use "grep -l" you obtain only names of the propper files ...

---

<div class="post-metadata">

**Author:** ![system](https://community.unix.com/uploads/default/original/2X/c/c7e9e16a595259edafe88615719d5c5dcda035c2.png) [@system](https://community.unix.com/u/system)\
**Post date:** [November 15, 2001, 9:50pm UTC](https://community.unix.com/t/find-files-containing-text/140295/4 "2001-11-15T21:50:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![guest100](https://community.unix.com/user_avatar/community.unix.com/guest100/32/37_2.png) [@guest100](https://community.unix.com/u/guest100)\
**Post date:** [November 16, 2001, 5:01am UTC](https://community.unix.com/t/find-files-containing-text/140295/5 "2001-11-16T05:01:46Z")

</div>

What I suggest is much easier

try :

\<pre\>

grep whatever /\*

\</pre\>

as simple as that.

That works with solaris !

---

<div class="post-metadata">

**Author:** ![system](https://community.unix.com/uploads/default/original/2X/c/c7e9e16a595259edafe88615719d5c5dcda035c2.png) [@system](https://community.unix.com/u/system)\
**Post date:** [November 16, 2001, 9:28am UTC](https://community.unix.com/t/find-files-containing-text/140295/6 "2001-11-16T09:28:48Z")

</div>

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.
