![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Perl code to differentiate numeric and non-numeric input | Raynon | Shell Programming and Scripting | 11 | 08-04-2007 11:32 AM |
| Checking numeric value | malaymaru | Shell Programming and Scripting | 6 | 05-25-2007 09:42 PM |
| non-numeric argument | TiredOrangeCat | UNIX for Dummies Questions & Answers | 3 | 02-13-2007 02:37 AM |
| validating variables (numeric) | pjd1 | Shell Programming and Scripting | 3 | 11-28-2006 12:18 PM |
| Numeric CHMOD for .js files | Texan | UNIX for Advanced & Expert Users | 3 | 02-11-2006 06:15 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Numeric Validation
Hi, How to check whether an input to a shell script contain only numeric values. Is there any way to check against the following characters. & ( ) | \ " ' < > ` I've used the following way. Code:
echo $1 | grep "[^0-9]\{2\}$"
if [ $? -eq 0 ]
then
echo "OK"
else
echo "Error"
fi
But, in this case there are two issues. 1) If the input contains numeric values the input value will be displayed which i don't want. 2) If special characters mentioned above are included, the script fails. I've given up. I would really appreciate if anyone can help me out. Thanks, Sumesh |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|