Download your favorite Linux distribution at LQ ISO.
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, 04: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, 05:01 AM   #2
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198
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, 08:05 AM   #3
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
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 34 10-12-2016 08:09 AM
how to get integer part from string in Shell Script sunilvadranapu Programming 4 11-02-2008 04:51 AM
shell command to find the number of collisions of NICs RajRed Linux - Newbie 14 04-19-2006 01:20 PM
Shell-script question about getting a number as a variable stormrider_may Programming 9 03-14-2006 08:18 AM
Shell-Script check if $xx is of type integer d-fens Programming 5 07-11-2003 08:38 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:56 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
Open Source Consulting | Domain Registration