Find files containing text in Linux

Last updated on December 1st, 2010 at 12:36 am

grep -lir "text you want to find" *
You could put it as background if it is longer time search

grep -lir "text you want to find" * > searchresult.txt &

[adrotate banner=”1″]
I want to search ‘archives/simple’ in my ‘data’ directory

cd ./data/
grep -lir "archives/simple" * > searchresult.txt &

After done, then you can type
cat searchresult.txt
then you will know which files contain the text.
If you want to know which line that contain the text
You could type
cat data/bbscache/index.html | grep "archives/simple"
*** data/bbscache/index.html is my example result.
[adrotate banner=”2″]


Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.