echo + bc + format

Hi,

I was trying to define a variable as a result of an operation,

b=` echo $a+1 | bc -l`

with a specific format (5 digits integer completing with zeros, 00025, for example)

c=` printf "%05d\n" b `

Does anyone how can it be done in one step in bash shell to get the formatted variable c? Thanks in advanced

With recent versions of bash:

$ unset c
$ printf -vc %05d $((5*5))
$ echo $c
00025

With older versions:

$ unset c
$ c=$(printf %05d $((5*5)))
$ echo $c
00025

Thanks a lot! the second way works perfectly!!