I have a basic number for loop which increments the variable num by 1 over each iteration…

for (( num=1; num<=5; num++ ))
do
 echo $num
done

Which outputs:

1
2
3
4
5

I’m trying to make it produce the output (add leading zero before $num):

01
02
03
04
05

Without doing:

echo 0$num

7 Answers
7

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *