How to find files containing specific text?
I have misplaced a file and I don't even remember its filename. But I do know some of the text inside this file. So is there a way I could search for files containing that text?
|
You could probably use any of the following commands: grep, egrep or fgrep. See the man pages for more details.
|
There's probably a really easy way to do it from the command line, but I can't think of any, so kfind will have to do for my suggestion.
|
Ooh! Split second there Drew!
|
I can only use command line tools. I do not have a GUI
|
Well than grep and find combined should work
find / -type f -exec grep -i pattern '{}' \; -print it will take some time but if you know approximatelly directory where the file might be you can shorten the path just to start from this directory, suppose the file is somewhere in /home -> find /home -type f -exec grep -i pattern '{}' \; -print |
go over to the directory where you think is the file and then write!!
grep -r "STRING THAT YOU WANT" * |
Quote:
grep -rl "STRING THAT YOU WANT" * Also note that this does not search hidden directories. The find examples given previously do. I prefer to use xargs in combination with find and grep since it doesn't suffer any size limitations. These find examples will show you the names of the files that contain the pattern or "STRING THAT YOU WANT" find / -type f | xargs grep -l pattern or from the current working directory cd /somedirectory find . -type f | xargs grep -l "STRING THAT YOU WANT" |
All times are GMT -5. The time now is 08:38 AM. |