if(( $#==0 )) then echo -e "Invalid number of arguments provided" else vow=0 cons=0 for str in $* do #len=`echo $str | wc -c` len=`expr length $str` for(( i=1;i<=len;i++ )) do char=`echo $str | cut -c $i` case $char in a) (( vow=vow+1 )) ;; A) (( vow=vow+1 )) ;; e) (( vow=vow+1 )) ;; E) (( vow=vow+1 )) ;; i) (( vow=vow+1 )) ;; I) (( vow=vow+1 )) ;; o) (( vow=vow+1 )) ;; O) (( vow=vow+1 )) ;; u) (( vow=vow+1 )) ;; U) (( vow=vow+1 )) ;; *) (( cons=cons+1 )) ;; esac done done echo -e "\t\tINPUT: $*\n" echo -e "\t\tNo. of Vowels=$vow\n\t\tNo. of Consonants=$cons" fi
Search Here
Shell Script to count the number of consonants and vowels in sentence. The sentence is supplied as command line arguments
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment