In the example the string is “10987654321” and you want the 5 last characters of a string so “54321”:
Dans l’exemple la chaîne est “10987654321” et on veut les 5 deniers caractères donc “54321” :
#> echo "10987654321" |awk '{print substr($0, length($0)-4)}' 54321
En bash, ça t’évitera un fork
# toto=12345678
# echo ${toto:0:4}
# Et ce que tu veux
# echo ${toto:${#toto}-5}
# Ou encore
# echo ${toto#*4}
Voir bash expansion
++
Bonne astuce, mais bash n’est pas forcement disponible sur les anciens OS (c’était mon cas).