How to identify numeric Input
Hi guys when i execute my script it says integer expression expected .How would i handle this in my script please suggest.
Please Enter Your Age sa ./ifexercise.sh: line 7: [: sa: integer expression expected ./ifexercise.sh: line 10: [: sa: integer expression expected Please enter proper Input Content of my script. #!/bin/bash echo "Please Enter Your Age" read age retirement_age=65 if [ -z "$age" ] then echo "dont enter empty string" elif [ "$age" -gt $retirement_age ] then echo "You Should retire now" elif [ "$age" -le $retirement_age ] then echo "You are young" else echo "Please enter proper Input" fi |
See http://www.linuxquestions.org/questi...n-bash-279227/
(you didn't look very hard for the solution, didn't you?) |
I have Modified my script As follows:
#!/bin/bash echo "Please Enter Your Age" read age retirement_age=65 if [ -z "$age" ] then echo "dont enter empty string" elif [ ! `expr $age + 1 2>/dev/null` ] then echo "Please Enter Numeric Number" elif [ "$age" -gt $retirement_age ] then echo "You Should retire now" elif [ "$age" -le $retirement_age ] then echo "You are young" else echo "Please enter proper Input" fi |
Quote:
|
Use the top bar
Quote:
|
All times are GMT -5. The time now is 05:41 PM. |