![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
question?
Is there any way to use sed and count the number of alphabetic characters in a sentence?
|
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Is this homework?
|
|
#3
|
|||
|
|||
|
try this,
not thoroughly tested, Code:
# !/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 |
|
#4
|
||||
|
||||
|
Code:
echo '123abc237R,6|' | sed 's/[^a-zA-Z]//g' | wc -c |
|
#5
|
|||
|
|||
|
Quote:
Code:
count=$((`echo '123abc237R,6|' | sed 's/[^a-zA-Z]//g' | wc -c` - 1)) echo $count |
|||
| Google The UNIX and Linux Forums |