The UNIX and Linux Forums  

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




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #7 (permalink)  
Old 05-25-2007
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,380
Quote:
Originally Posted by malaymaru
How can I check numeric value in shell?

I am passing one parameter (integer) and I want to restrict any other characters except 0-9.

./script xyz 10

Here 2nd parameter (10) should be integer only.


Code:
case $2 in
  *[^0-9]*) echo not integer; exit 1 ;;
esac