Bash : test how can I refine the conditions ?
Hi,
The 'if' statement works fine in selecting a number from 0 to 68. What I cannot fathom is how to give the option of getting a suffixed number eg. 56c to work.I've searched high and low. I should be most grateful for a solution . Code:
echo |
Quote:
Why would you want to have an alphabetic character in a number? What are you trying to accomplish in the first place? |
Quote:
See (for example) http://tldp.org/LDP/abs/html/string-manipulation.html Daniel B. Martin |
Quote:
Code:
RawData="56c" Should return 56. You can work that into your script. |
This all depends as to whether you need to check for valid entry first versus parse something such as your example.
You haven't indicated yet whether or not "56c" is a legal or illegal input value. If it is legal input, then how do you interpret it? Hexadecimal? Or something else? So let us know if you're looking for how to deal with HEX numbers in a script, or if you need advice on how to qualify input a valid versus not. It's also confusing because your initial test validate between 0 and 68, and then suddenly you throw 56c into the mix ... that would be a way larger number if this were HEX, and if it's a meaningful punctuation character like "degrees C" then there's the option of stripping out the non-numeric parts like Ranamon says. You really have to qualify what range of input you wish to allow and determine how you intend to deal with illegal input. |
All times are GMT -5. The time now is 03:18 AM. |