1834137 Members
2221 Online
110064 Solutions
New Discussion

Re: search script???

 
SOLVED
Go to solution
KO kwang tae
Advisor

search script???

hello !

i want to find the file.
but i can't remember file name. only i know file contents.

so, i want to make shell script searching file contents that i find in all files

do you happen to know?
please~ help~
3 REPLIES 3
Umapathy S
Honored Contributor
Solution

Re: search script???

you can always do. Go into the top level directory and do

find . -type f -exec grep {} \; -print

HTH
Umapathy
Arise Awake and Stop NOT till the goal is Reached!
Darren Prior
Honored Contributor

Re: search script???

Hi,

There are better ways, but a quick and dirty approach could be:

find / -type f -exec grep -l yoursearchstring {} \;

or

find / -type f | xargs grep -l yoursearchstring

regards,

Darren.
Calm down. It's only ones and zeros...
raju_5
New Member

Re: search script???

Let's assume that you know a word "searchfile" and you want to find out the file name which has that word in it. Use

find / -type f -exec grep -l searchfile {} \;

If you want to list the search word from all file, the exclude the -l (ell) option
ie,

find / -type f -exec searchfile {} \;
RAJUSHANKAR