![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| ksh Checking if variable has 5 digits | developncode | UNIX for Dummies Questions & Answers | 3 | 04-08-2008 12:57 PM |
| Digits display | Spoorthi16 | UNIX for Dummies Questions & Answers | 3 | 10-01-2007 05:26 PM |
| making sure input are digits | bebop1111116 | High Level Programming | 1 | 10-21-2006 02:32 PM |
| How to cut last 10 digits off | psarava | Shell Programming and Scripting | 4 | 08-29-2006 12:52 AM |
| diff. b/t chars and digits | mezzanine | Shell Programming and Scripting | 1 | 11-17-2005 09:37 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Hi All,
I am new to shell script. I wrote a very small script that takes only digits as input- but there is some problem in that.can you help me in debugging that. #!/bin/ksh echo "Digits as input" read number digit='eval [0-9][0-9][0-9]' if [[ number -eq $digit ]] then echo "Entered number is a digit" else echo "0" fi Please modify this one or without AWK give me some inputs. Thanks, Namish |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Code:
#!/bin/ksh echo "Digits as input" read number test=`echo "$number" | egrep "^[0-9]+$"` if [ "$test" ] then echo "Entered number is a digit" else echo "0" fi |
|
#3
|
|||
|
|||
|
Thanks robotronic.
I appericiate your help and quick reply. Thanks Namish |
|||
| Google The UNIX and Linux Forums |
| Thread Tools | |
| Display Modes | |
|
|