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..
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..
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)
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...
when you use "grep -l" you obtain only names of the propper files ...
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
What I suggest is much easier
try :
<pre>
grep whatever /*
</pre>
as simple as that.
That works with solaris !
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.