![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Grep command | nickg | UNIX for Dummies Questions & Answers | 14 | 10-06-2008 11:22 AM |
| how to exclude the GREP command from GREP | yamsin789 | UNIX for Advanced & Expert Users | 2 | 10-05-2007 02:59 AM |
| grep command help | ishmael^soyuz | Shell Programming and Scripting | 4 | 07-11-2007 09:01 AM |
| grep command | pmsuper | UNIX for Dummies Questions & Answers | 6 | 11-22-2006 07:12 AM |
| grep command | debasis.mishra | Shell Programming and Scripting | 1 | 03-28-2006 01:53 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Numeric Check
As I know, there is no straight forward numeric check in shell script.
Through logic you can do. -- typeset -i num echo "Please enter string :" read str num=`expr $str + 1 2>/dev/null` if [ $? -eq 0 ] then echo "Entered string is a number $str" else echo "Entered string is not a number $str" fi -- Hope it will help Thanks Sumit |
|
||||
|
Be sure to add an extra check whether the user has given 0 as input when using sumitc's suggestion, which is the far better way to accomplish what you really want.
Generally one could render your idea in a more elegant way as follows Code:
read value value=`echo $value|grep -w [0-9]` |
|
||||
|
grep command
hi,
that does work but it doesnot support input more than one digit if i want to enter number with 2 digits, the command does not work, what should i alter to allow the code to read input of more than one digit? thanks |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|