Use apenas sprintf
:
BEGIN {
myarray["01"]
myarray["02"]
myarray["04"]
myarray["05"]
# ... etc, up to "12"
for (i = 1; i <= 12; i++) {
k = sprintf("%02d", i)
if (! (k in myarray)) {
print k " is missing from myarray"
}
}
}
deu a você:
03 is missing from myarray
06 is missing from myarray
07 is missing from myarray
08 is missing from myarray
09 is missing from myarray
10 is missing from myarray
11 is missing from myarray
12 is missing from myarray