Add leading zeroes to awk variable
Here's how to create leading zeros with awk
:
# echo 1 | awk '{ printf("%02d\n", $1) }'
01
# echo 21 | awk '{ printf("%02d\n", $1) }'
21
Replace %02
with the total number of digits you need (including zeros).
Replace file
on output with sprintf("%02d", file)
.
Or even the whole assigment with filename = sprintf("%s_%02d.pdb", pdb, file);
.