# 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
# You can do it in two ways
# 1) Let "grep" read on its standard input
echo "$line" | grep -o select
# 2) tell "grep" here is the string
grep select <<< "$line"
output=$(command)
[[ $output =~ (CpuIowait=[0-9][.][0-9]{2}) ]] && echo "${BASH_REMATCH[1]}"