Tuesday, 11 June 2013

shell script to accept a character from the user and check whether the word begins with vowel or begins with digit or ends with digit or is a four lettered word or a consonant.

Code:
echo Enter the word
read str
case $str in
[aeiou]*) echo The word begins with a vowel;;
  [0-9]*) echo The word starts with a digit;;
  *[0-9]) echo The word ends with a digit;;
    ????) echo The word entered is 4 lettered word;;
       *) echo The word entered is either starts with a
          consonant or incorrect input;;
esac

Output:
[ty2011330@localhost ~]$ sh file12.sh

Enter the word
a
The word begins with a vowel

Enter the word
hello
The word entered is either starts with a consonant or incorrect input

Enter the word
film
The word entered is 4 lettered word

Enter the word
*9
The word ends with a digit

No comments:

Post a Comment