coreutils

printf

printf -v formatted "%03d" ${raw}