bash string comparison
My script takes user input and compare it with some values. It works fine when it compares against 0.00 or 10 or 100. But if the user input is something like "-0.009" it gives error - "integer expression expected in line 7 and 9" where it ought to print the number like -
your number is -0.009. Here's the code - Code:
if [ "$num" = 0.00 ] || [ "$num" -le 10 ]; then # this is line 7 |
For floating point operations, you need to invoke bc. See the Advanced Bash-Scripting Guide for examples.
Alternatively, you can use another scripting language. |
All times are GMT -5. The time now is 02:39 PM. |