Skip to main content

shell- find occurence of a character or a word within another string - bash


echo "enter a string"
read s

echo "enter a word to search in string"
read search_word

s2=` echo $s | grep -o $search_word | wc -l `

echo "The number of occurences is $s2"

Comments

Popular posts from this blog

unix commands