Write a Bash script to print count of numbers, count of vowels and count of consonants in a given text - Tecnew

Home Ads

Write a Bash script to print count of numbers, count of vowels and count of consonants in a given text

Write a Bash script to print count of numbers, count of vowels and count of consonants in a given text

Share This

Below Bash script will give the output count of Numbers, Vowels, and Consonants


 #!/bin/sh
echo -n "Enter a line of text: "
read string
numCount=$(echo $string | grep -o "[0-9]" | wc -l)
vowCount=$(echo $string | grep -o -i "[aeiou]" | wc -l)
consCount=$(echo $string | grep -o -i "[bcdfghjklmnpqrstvwxyz]" | wc -l)
echo "Count of vowels $vowCount, $consCount consonants and $numCount numbers in it."

No comments:

Post a Comment