I want to run a for loop in awk with leading zeros in the index variable.
This isn't for printing a number with leading zeros, which I could easily handle with a printf statement. It's for checking if the given number (with leading zeros) has been used as an index in an array.
So what I actually want is to iterate through string values in awk, from "01" to "14" (or whatever).
Something like:
myarray["01"]
myarray["02"]
myarray["04"]
myarray["05"]
# ... etc, up to "12"
for (i = 01; i <= 12; i++) {
if (! (i in myarray)) {
print i " is missing from myarray"
}
}
Should report that "03 is missing from myarray." But that's not how it works.
How can I do this?