I need to search the string "Linux" in a web page, first in case-sensitive, sencond in case-insensitive.
Well, my search will be in http://www.tldp.org/LDP/intro-linux/html/intro-linux.html
I made the bellow code, but it is not return every words "Linux".
echo Linux: $(grep -wc "Linux" ~/workspace/ep-exercicios/m1/e2/intro-linux.html)
grep counts matching lines, so lines with multiple matches are counted only once.
echo "Linux Linux Linux" | grep -woc Linux 1
You could use the
-o flag to generate one line per match, then
wc -l to count
echo "Linux Linux Linux" | grep -o Linux | wc -l 3