The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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
Ksh How to test if variable is numeric?? developncode UNIX for Dummies Questions & Answers 8 03-19-2009 06:42 PM
check the given string is numeric or not. knowledge_gain High Level Programming 11 02-03-2009 11:25 AM
Check for numeric inputs Raynon Shell Programming and Scripting 6 08-22-2007 03:17 AM
How to check for a valid numeric input Vijayakumarpc Shell Programming and Scripting 1 08-04-2007 08:34 AM
How to check a column contain numeric or char data type ?? jambesh Shell Programming and Scripting 12 10-06-2006 10:37 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-06-2007
sachin.gangadha sachin.gangadha is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 37
to check variable if its non numeric

if test $b -ne [0-9]
then
echo "\n\n\n\tPassword reset has been done successfully"
else
echo "\n\n\n\tAn error occurred"
fi

i want to check whether $b is non-numeric so how to do that?
  #2 (permalink)  
Old 12-06-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
Code:
case "$b" in 
[0-9] ) 
        echo numeric 
        ;;
* ) 
        echo alpha 
        ;;
esac
  #3 (permalink)  
Old 12-06-2007
sachin.gangadha sachin.gangadha is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 37
Thanx porter but in this case i would like to use if then instead of case. Damn! two many cases. lolz
  #4 (permalink)  
Old 12-06-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
Put the case in a function called isnumeric, then use if to call the function.
Sponsored Links
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 06:38 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