•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Legacy and Other Languages section within the Software Development category of DaniWeb, a massive community of 392,008 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,222 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Legacy and Other Languages advertiser:
Views: 67895 | Replies: 4
![]() |
•
•
Join Date: Jun 2005
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
How to compare a number stored as string to an integer value in shell scripting? Here is what I have,
if [$temp -ge 2.5] then;
when I run the above code, it gives the error as "Integer Expression expected".
Here the temp variable contains the number "3.0" as a string, I want to compare the value of temp is greater or equal to the number 2.5.
How can I do it.
Please reply soon.
Thanks in advance.
Shiva
if [$temp -ge 2.5] then;
when I run the above code, it gives the error as "Integer Expression expected".
Here the temp variable contains the number "3.0" as a string, I want to compare the value of temp is greater or equal to the number 2.5.
How can I do it.
Please reply soon.
Thanks in advance.
Shiva
•
•
Join Date: Aug 2005
Location: North of the equator, but south of anywhere it could get cold for long
Posts: 25
Reputation:
Rep Power: 4
Solved Threads: 0
Try putting quotes around 2.5 and $temp like so:
otherwise set a variable equal to 2.5 and test that:
This may require quotes too so...
These suggestions are based on BASH shell scripting which is what this kind of looks like, so your mileage may vary...
if ["$temp" -ge "2.5"] then;
SOME_VALUE=2.5 if [$temp -ge $SOME_VAULE] then;
These suggestions are based on BASH shell scripting which is what this kind of looks like, so your mileage may vary...
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Legacy and Other Languages Marketplace
Similar Threads
- String to integer conversion (C)
- Convert a string to an integer (PHP)
- Convert string "aA" to a BigInteger (Java)
- Converting String to Integer help (C++)
- String to integer to ascii (C)
Other Threads in the Legacy and Other Languages Forum
- Previous Thread: VB 1.0 Toolbar
- Next Thread: MS Batch File Copying


Linear Mode