STR1='hello123\&*' # Count kinds of chars by removing them with sed and measuring how many were removed. STR2=`echo "$STR1" | sed 's/[a-zA-Z]//g'` LEN2=`expr "${#STR1}" - "${#STR2}"` echo "$LEN2 alphabetic chars" STR3=`echo "$STR1" | sed 's/[0-9]//g'` LEN3=`expr "${#STR1}" - "${#STR3}"` echo "$LEN3 digits" STR4=`echo "$STR1" | sed 's/[^a-zA-Z0-9 \t]//g'` LEN4=`expr "${#STR1}" - "${#STR3}"` echo "$LEN4 specials"
$ ./script 5 alphabetic chars 3 digits 3 specials $