-1

I want to make the following directories using shell script,

00, 01, 02, ..., 50

I have tried the script as follows:

for ((1;i<=${1};i=i+1))
do
mkdir ${i}
done

But I get

0, 1, 2, ..., 50

How to modify the script? thanks.

San Tseng
  • 33
  • 1
  • 4
  • 2
    printf(1) will help get the number into the appropriate format. – Shawn Aug 14 '18 at 01:53
  • Possible duplicate of [How to add leading zeros for for-loop in shell?](https://stackoverflow.com/q/18460123/608639), [How to zero pad a sequence of integers in bash so that all have the same width?](https://stackoverflow.com/q/8789729/608639), etc. – jww Aug 14 '18 at 03:15

1 Answers1

0
for i in $(seq -f "%05g" 0 50)
do
  mkdir $i
done

should do the trick.

Bibek Shah
  • 419
  • 4
  • 19