LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices

Reply
 
Search this Thread
Old 08-15-2009, 04:38 AM   #1
kvmreddy
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
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,541
Blog Entries: 28

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
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.
 
Old 08-15-2009, 08:05 AM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

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


Reply


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 11:29 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


All times are GMT -5. The time now is 11:26 AM.

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