I have an array ${myarr[@]} with strings. ${myarr[@]} basically consists of lines and each line constists of words.
${myarr[@]}
world hello moo
No need for an external program:
count=0 for word in ${myarr[*]}; do if [[ $word =~ hello ]]; then (( count++ )) fi done echo $count