If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > need help

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-30-03, 05:31
keerthi keerthi is offline
Registered User
 
Join Date: Nov 2003
Posts: 1
Exclamation need help

Hi all,

Im new to unix. Im trying to write simple shell scripts. I need the script for one simple question.
My question is

I need to accept a string. From that string i need to display how many vowels, consonants and number of digits from the sting

Please help me.

I accept im totally zero in unix concepts
Reply With Quote
  #2 (permalink)  
Old 11-30-03, 17:37
fla5do fla5do is offline
Registered User
 
Join Date: Oct 2003
Location: Germany
Posts: 138
try this :

clear
echo "Please insert your string and then press ENTER"
read a
echo $a | awk ' BEGIN { FS="@"}
{
dummy=0
vowels=0
consonants=0
lang=length($1)
while ( lang != dummy )
{
dummy=dummy+1
if ( substr($1,dummy,1) == "a" )
{
vowels=vowels+1
}
if ( substr($1,dummy,1) == "e" )
{
vowels=vowels+1
}
if ( substr($1,dummy,1) == "i" )
{
vowels=vowels+1
}
if ( substr($1,dummy,1) == "o" )
{
vowels=vowels+1
}
if ( substr($1,dummy,1) == "u" )
{
vowels=vowels+1
}
}
} END {
consonants=dummy-vowels
print "you have "vowels" vowels in your string"
print "you have "consonants" consonants in your string"
print "your string is "dummy" characters long"
}'
__________________
Greetings from germany
Peter F.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On