# It can be done in two ways
# 1) Have "grep" read on from the standard input using a pipe
# and search the input string. Then pipe the result to "wc" to count
# the number of occurences
$ line="This is where we select from a table."
# substr="select"
$ echo "$line" | grep "$substr" | wc -l
# 2) or pass a string to "grep" and search the string for a substring
# pass the result to "wc" to count the number of occurence
$ grep "$substr" <<< "$line" | wc -l