Actually, my point was not about anything that uses validation. That whole thing was a trip down a rabbit hole.
The OP insisted that there was no way that a variable could be treated as "polymorphic", I showed two shell examples to the contrary. i.e., 01 and 1 would register as 1 in
The only conclusion was that OP was using an ancient shell, so I suggested typeset. Then we all went down a rabbit hole. We are still there.
To answer your question in the OP's context let's see what ksh88 on Solaris 10 "thinks":
output:
Now let's compare that to bash and bash plus RE - note change to RE
output:
Hmm. ksh88 is the oldest shell I have. So none of the other stuff is really needed to do what the OP appears to have wanted, IMO. This was my original point. Your point is that signed numbers fail the RE in my example, which is true. My bad. Fixed.
All of this might have been over the OP's level of understanding anyway.
This User Gave Thanks to jim mcnamara For This Post:
Now change the character '1' to a '9' and see what you get.
Apart from the fact that with the OP's example any ASCII character can be 'read' so can octal _numbers_, valid numeric characters but invalid _integer_ results.
I get 2 numbers from a user and pass those 2 numbers to a function but it keeps on converting the numbers back to a string, so my function keeps crashing. If I was to hard code the numbers into the function then it works perfectly.
I tried this and it doesn't work
I tried this and it doesn't work
I even tried this and it doesn't work But this work
Is there a way I can get the numbers to remain as an integer instead of changing to a string by default? Thank you
Hello Guys,
I have a floating point number 1.14475E+15 I want to convert this number in to full number (Integer or Big integer). I tried couple of functions it did not work. When I use INT=${FLOAT/.*} I am getting value as 1. I don't want a truncated value
#!/bin/bash
#... (9 Replies)
I have data as below
"ROWS merge process complete. thousand rows changed"
I need to get a variable assigned the value of 1000. I mean convert the string thousand to 1000.
Any help or pointer.
Please use CODE tags as required by forum rules! (6 Replies)
friends
as I can convert this value to number
in this example it is well but can vary the value does not help me cut from a nesecito espefifica opsiocn get zero
CantCabe = 00023
Cant = 23
CantPntCabe = 0000000000000034
CantPnt = 34
if && ; then
echo... (3 Replies)
Hi gurus,
I have a weird requirement. I need to convert the number to english lecture.
I have 1.2 ....19 numbers
I need to convert to first second third fourth, fifth, sixth...
Is there any way convert it using unix command?
thanks in advance. (8 Replies)
I need to search the file using strings "Request Type" , " Request Method" , "Response Type" and by using result set find the xml tags and convert into a single line?. below are the scenarios.
Cat test
Nov 10, 2012 5:17:53 AM
INFO: Request Type
Line 1.... (5 Replies)
I have a txt file as database. when i run my program what it does is it ask me for 3 name and stored in the file as
name1:name2:name3:1
when u enter 3 name it add those in file as above format and add 1 at the end. I what i want is if i enter same names again it changes that 1 to 2 and so... (3 Replies)
Hi,
I am using awk to get particular dates in seconds and the output am getting is like 1.28071e+09.
How can I convert it to number format.
Can anyone help me out?
Thanks in advance..! (7 Replies)
hi ,
i need a script to convert number into hexadecimal base
for example: 237=>ED
it s very important for me thank you in advance for you help (5 Replies)
I want to make a script to read a list of ip addresses from a file then convert those ip addresses to ip number.
ip number is made by removing the dots then transfer to a number , so the ip number transfered to binary then to decimal which will represents the ip number 0 : 4294967295
Also I... (17 Replies)