Removal of insignificant zeros from a variable
Solved
Hello,
I'm following up on a similar request made a while ago. I'm experiencing the same issue (I want to remove the insignificant leading zeros from an alphanumeric variable that contains only digits).
I copied exactly the example that was given back then.
If I apply the recommended solution directly from the command line, it works.
However, as soon as I put it into a shell script, I do not get the expected result at all:
Well, I'm on CentOS7 Linux. It must be something simple. Maybe I'm missing something....
Thanks for your replies
Configuration: CentOS Linux release 7.5.1804 (Core)
I'm following up on a similar request made a while ago. I'm experiencing the same issue (I want to remove the insignificant leading zeros from an alphanumeric variable that contains only digits).
I copied exactly the example that was given back then.
If I apply the recommended solution directly from the command line, it works.
>var=0000001253; echo ${var##*(0)}
1253 However, as soon as I put it into a shell script, I do not get the expected result at all:
>cat test.sh
#!/bin/bash var=0000001253; echo ${var##*(0)} >test.sh
0000001253
Well, I'm on CentOS7 Linux. It must be something simple. Maybe I'm missing something....
Thanks for your replies
Configuration: CentOS Linux release 7.5.1804 (Core)