How to generate a fixed format, sequential integers

The following bash script is to generate integers from 1 to 11, having 3-digit format.

#!/bin/bash
for i in `seq -f "%03g" 1 11`
do
   echo $i
done 
exit 0 

The result is as follows.

 001
 002
 003
 004
 005
 006
 007
 008
 009
 010
 011

About albertsk

Professor at the University of Hawaii
This entry was posted in Uncategorized and tagged , . Bookmark the permalink.