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
With GNU awk for multi-char RS:
$ awk -v RS='\\' 'END{print (NR ? NR-1 : 0)}' file 4
or with a shell variable:
$ tofind='Apple' $ awk -v RS='\\<'"$tofind"'\\>' 'END{print (NR ? NR-1 : 0)}' file 4