Posts Tagged ‘find text’

The power of less

Monday, November 30th, 2009

Goal: I want to find some text called mytext within all php files in a directory. I also want to display all the matches and highlight them.
If this is what you want try this:

grep -Hin "mytext" *.php | less +/mytext

find everything except something using grep

Monday, September 28th, 2009

the -v switch is used to return negative results. So, to find everything which does not contain “findme” use

cat filename | grep -v "findme"

Find some text within files

Monday, September 28th, 2009

To find “findme” (case-insensitive) in all html files in /var/www/html directory use

find /var/www/html -name "*.html" -exec grep -i -l "FiNDmE" {} \;

To find “findme” (case-sensitive) in all html files in /var/www/html directory use

find /var/www/html -name "*.html" -exec grep -l "findme" {} \;