If I have the text in a shell variable, say $a:
$a
a=\"The cat sat on the mat\"
How can I search for \"cat\" and return 4 using a
I used awk for this
a="The cat sat on the mat" test="cat" awk -v a="$a" -v b="$test" 'BEGIN{print index(a,b)}'