exercise10
Exercise 10. Write a shell script that asks user to enter an character and then displays that the enter is either form small 'a-z' or capital 'A-Z' or a number '0-9' or any special character like $,?,etc. and if user enter any other value then display message accordingly.
Script: Here we take input from user and store it in 'chr' variable then use case function where we use [ ] in which we defined the characters which we want to validate then if the pattern matches we displayed the message accordingly.
Output: If user enter small 'a'
Output: If user enter capital 'F'. We will not get the expected output. For that we have to set our language to C. For that just enter the command LANG=C as shown below.
Output: If user enter a number '3'
Output: If user enter a special character '@'. Here we get the output for only those characters which we specified in our case as in our example we specified [?@#$] these only.
Output: If we entered any other character as here we entered '^' which is not specified anywhere in any case.
No comments:
Post a Comment