For the file file1.txt which contains
file1.txt
Apple fruit Apple tree Tree AApple AApklle Apple apple TREE Apple
I want to find number of o
You can change the grep line to:
grep -o '\<'"$TOFIND"'\>' "$FILE" | wc -l
or just:
grep -o "\<$TOFIND\>" "$FILE" | wc -l
Then it will work. It's because the quotes, your double quotes was quoted inside single quotes, so they are not expanded.