Did you know LQ has a Linux Hardware Compatibility List?
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 08-15-2009, 05:38 AM   #1
LQ Newbie
Registered: Aug 2009
Posts: 15

Rep: Reputation: 3
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
Old 08-15-2009, 06:01 AM   #2
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian except for netbook still on Slackware 13.37 (and I have to support Ubuntu)
Posts: 8,572
Blog Entries: 30

Rep: Reputation: 1182Reputation: 1182Reputation: 1182Reputation: 1182Reputation: 1182Reputation: 1182Reputation: 1182Reputation: 1182Reputation: 1182
You mean an argument passed to the script when it is started? As in
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.
Old 08-15-2009, 09:05 AM   #3
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 735Reputation: 735Reputation: 735Reputation: 735Reputation: 735Reputation: 735Reputation: 735
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.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I compare floating number in a shell script? abefroman Programming 29 09-10-2012 12:29 PM
how to get integer part from string in Shell Script sunilvadranapu Programming 4 11-02-2008 05:51 AM
shell command to find the number of collisions of NICs RajRed Linux - Newbie 14 04-19-2006 02:20 PM
Shell-script question about getting a number as a variable stormrider_may Programming 9 03-14-2006 09:18 AM
Shell-Script check if $xx is of type integer d-fens Programming 5 07-11-2003 09:38 AM

All times are GMT -5. The time now is 12:06 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration