Joined January 2015

Jesus Ramirez

Greater Chicago Area

If I run the following at the bash promt:</p>
$ var="00087" $ newvar=${var##+(0)} $ echo $newvar </pre> </code> The results are as expected. The leading zeros are removed. However, once I put this in a script; it does not work. It does not remove the leading zeros. The shopt commands returns extglob on. I'm confused. </p> Now, look at this script:</p>


This works but if value of var=087 then it does not, that would yield 087

echo $newvar

This one works great as long as there are no zeros at the end

because a value like 320, 10, 50 200 would yields a blank.


echo $newvar // yields: a blank

This works as long as there are no zeros at the end. Well, that is not good either. Now what do I do? I guess I use sed.</p>

1 Karma
0 Total ProTip Views