How to zero-pad numeric variables in zsh (and maybe also bash?)
For reference sake, if you do not have control over the generation of the numeric values, you can do padding with:
% value=314
% echo ${(l:10::0:)value}
0000000314
% echo $value
314
Use the -w
flag to seq
(in any shell):
$ seq -w 1 10
01
02
03
04
05
06
07
08
09
10