LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to find given number is integer or not in shell script (http://www.linuxquestions.org/questions/linux-newbie-8/how-to-find-given-number-is-integer-or-not-in-shell-script-747719/)

kvmreddy 08-15-2009 04:38 AM

how to find given number is integer or not in shell script
 
can anybody help me to find supplied number to a shell script
is a number or not

catkin 08-15-2009 05:01 AM

You mean an argument passed to the script when it is started? As in
Code:

myscript some_argument
In that case "some_argument" would be $1 in the script and it is a string which may or may not be a number.

To advise on how to test whether it is a number, you will have to tell us what you mean by number: (un)signed integer, float (with how many decimal places?), exponential format, binary, octal, hex, maximum size ... "number" on its own is an imprecise term in computing.

pixellany 08-15-2009 08:05 AM

Is this homework?

Do you mean integer or number? (Your title says integer, text says number.)

Note that BASH does not deal with anything but integers.


All times are GMT -5. The time now is 03:49 PM.