The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



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
ksh Checking if variable has 5 digits developncode UNIX for Dummies Questions & Answers 3 04-08-2008 04:57 PM
Digits display Spoorthi16 UNIX for Dummies Questions & Answers 3 10-01-2007 09:26 PM
making sure input are digits bebop1111116 High Level Programming 1 10-21-2006 06:32 PM
How to cut last 10 digits off psarava Shell Programming and Scripting 4 08-29-2006 04:52 AM
diff. b/t chars and digits mezzanine Shell Programming and Scripting 1 11-18-2005 12:37 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-21-2007
namishtiwari namishtiwari is offline Forum Advisor  
Registered User
  
 

Join Date: Aug 2007
Location: Bangalore
Posts: 377
Lightbulb Only Digits as input

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
  #2 (permalink)  
Old 08-21-2007
robotronic's Avatar
robotronic robotronic is offline Forum Advisor  
Can I play with madness?
  
 

Join Date: Apr 2002
Location: Italy
Posts: 370
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 (permalink)  
Old 08-21-2007
namishtiwari namishtiwari is offline Forum Advisor  
Registered User
  
 

Join Date: Aug 2007
Location: Bangalore
Posts: 377
Thumbs up

Thanks robotronic.

I appericiate your help and quick reply.

Thanks
Namish
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:00 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0