Is there any way to use sed and count the number of alphabetic characters in a sentence?
Is this homework?
try this,
not thoroughly tested,
# !/usr/bin/ksh
word="count of no of characters"
cnt=0
curr=""
match=""
while :
do
match=$match"."
if [ curr = `echo $word | sed -e "s/$match//"` ] 2>/dev/null
then
break;
fi
cnt=$(($cnt + 1))
done
cnt=$(($cnt + 1))
echo "word count: $cnt"
exit 0
echo '123abc237R,6|' | sed 's/[^a-zA-Z]//g' | wc -c
the above cnt would include the terminating character also
count=$((`echo '123abc237R,6|' | sed 's/[^a-zA-Z]//g' | wc -c` - 1))
echo $count