How can get the value 001 using shell script

Hi Gurus,

Please help in this shell script.

x=000
y=`expr $x + 1`
echo $y

which gives me the value as 1

How can i get the value as 001 in this shell script. As i am new to scripting stuck up here.

Requesting here help here

Instead of echo use the below...

printf "%03d" "$y"

You can also use typeset:

x=0
typeset -Z3 y=$(expr $x + 1)
echo $y
001