Skip to content

Instantly share code, notes, and snippets.

@FleXoft
Created November 7, 2018 14:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FleXoft/86a066e2d769b66964638000c1590875 to your computer and use it in GitHub Desktop.
Save FleXoft/86a066e2d769b66964638000c1590875 to your computer and use it in GitHub Desktop.
Numbered for-loop in shell with leading zeros
for (( num=1; num<=5; num++ )); do printf "%02d\n" $num; done
seq -f '%02g' 1 5
for num in $( seq -w 01 05 ); do echo $num; done
// from bash 4.0 onward
echo {01..05}
for num in {01..05}; do echo $num; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment