i m not in front of my unix server so can not give exact answer
but to find occurance of character in string u can try following:
no_of_occurance=`expr "string" : 'char_name'`

i think this should work