How to search text in all text files of all the sub-directories ?
Hi !
Currently, when I'm searching text in files of my PHP project, I use this line : Code:
grep -r 'myTextToFind' * How can I do that ? Thanks ! -Pit |
find / -name '*.lang' | grep -r 'myTextToFind' *
assuming root(/) is your topmost directory you want to search from. |
Thank you but it's not working : it search in all the files, not only in "*.lang" files.
|
grep "string to find" `find . -name "*.lang"`
The back quotes ` generate file names for file argument to grep bs |
Code:
find / -name '*.lang' -print | xargs grep 'string to find' Cheers, Lou EDIT: If you don't want to run into permission problems, execute as root. |
One could also use the exec option of find,
Code:
find / -type f -name '*.lang' -exec grep 'string to find' '{}' \; Quote:
If you need to get the filenames where the matches were found as well, use the -H option for grep. Also, '*.lang' matches any file whose suffix is 'lang', but you only need to specify the dot if you (might) have files that end with 'lang' (i.e. 'thislang', 'thatlang' and so on, but not 'thislang.xxx' because it doesn't end with 'lang'). |
Thanks bOuncer.
Lou |
OK, thanks for all this !
That helped me to have this command that does exactly what I wanted : Code:
grep -H "nb" `find . -name "*.lang"` |
All times are GMT -5. The time now is 11:53 AM. |