26 Aug
2013
26 Aug
'13
18:22
[26.08.2013 19:14] [Greg Freemyer]:
All,
I have a script that gets to a line equivalent to:
echo $((0024748032 * 512))
It dies because it is interpreting that as octal (I assume).
How can I trim off the leading zeros?
Hi Greg, I tried ${var##0}, but this did not work. It only eliminates one 0. So I tried to convince the bash that 0024748032 is a decimal number, and it worked: MYVAR=0024748032 MYVAL=10#$MYVAR echo $((MYVAL * 512)) If the numbers are hardcoded, you can write echo $((10#0024748032 * 512)) and everything is fine, but I suspect that you use variables ;-) Now I hope that you use bash... Werner -- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org