Find files containing text in Linux

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 &

example.

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.


Tags: , , ,

Translate

Buy me a Caffè Latte

Thank you for the Caffè Latte

2013/02/15 saw art
2013/01/25 Parul Patel
2012/11/20 Barbara Nicholas $10
2012/10/08 Amy Stockman $5
2012/07/15 siewho chang $ 50
2012/06/08 Susan Hampton $10
2012/05/11 Chris Grima $10