How to search for a string in all the files irrespective of directory.?

Hi All,

How to search for a string in all the files irrespective of directory.

If I use

grep -i 'hello' *.*

It will search for the string hello in the files of current directory.

But I want to check for the string hello in the files of all the directories.

Thanks

Hello ROCK_PLSQL,

Please use code tags while using Inputs/codes/commands into your posts as per forum rules.
You could go through the rules of forum into as follows link too.

Now coming onto your requirement, could you please try following and let me know if this helps you.

find -type f -exec grep -l "test_text" {} \+

Please try above and let us know how it goes, if you have more conditions and requirements please mention all in post too.

NOTE: Above will provide you all the files details(only names of files) which have string test_text in them.

Thanks,
R. Singh

Does your grep offer the -r option?

Hi,

I have tried this

 find -type f -exec grep -l "hello" {} \+

got the error

find: illegal option -- t
find: [-H | -L] path-list predicate-list
grep -r

is not supporting.

Thanks

---------- Post updated at 07:32 PM ---------- Previous update was at 05:09 PM ----------

Hi ALL,

Please help me.

Thanks

That should be find . -type f -exec grep -l "test_text" {} + (with the dot and without the \ )

1 Like