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
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
the -v switch is used to return negative results. So, to find everything which does not contain “findme” use
cat filename | grep -v "findme"
Use --color=auto with grep to highlight the matches
cat somefile | grep --color=auto "findme"
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" {} \;