Zero padded integer in BASH
Let say we are trying to print
We can do that, using the following command
If we echo the ${a} variable, we will see the desired formatted integer i.e.
01
We can do that, using the following command
i=1
a=`printf "%0*d\n" 2 $i`
If we echo the ${a} variable, we will see the desired formatted integer i.e.
01
Comments
Post a Comment