linux - Adding two numbers with zero padding in bash shell -
var1=00001 var2=00001 expr $var1 + $var2
expected result: 00002
actual result: 2
how can expected result in bash?
you can this:
printf "%05d\n" $(expr $var1 + $var2)
var1=00001 var2=00001 expr $var1 + $var2
expected result: 00002
actual result: 2
how can expected result in bash?
you can this:
printf "%05d\n" $(expr $var1 + $var2)
Comments
Post a Comment