Skip to content

Instantly share code, notes, and snippets.

@ThibautVerron
Last active August 29, 2015 14:16
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 ThibautVerron/1a9da23bf7dafbc01d20 to your computer and use it in GitHub Desktop.
Save ThibautVerron/1a9da23bf7dafbc01d20 to your computer and use it in GitHub Desktop.
% for ((i=0;i<10;i++)); do printf "i=%s var=%s res=%s\n" $i $var ${var:${#var}-$i}; done
i=0 var=12345 res=
i=1 var=12345 res=5
i=2 var=12345 res=45
i=3 var=12345 res=345
i=4 var=12345 res=2345
i=5 var=12345 res=12345
i=6 var=12345 res=5
i=7 var=12345 res=45
i=8 var=12345 res=345
i=9 var=12345 res=2345
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment