printf "%5.5\n" "1234567890"
will print 12345 . How do I get it to print
67890
Essentially, I just want the last 5 characters rather than the first 5.
printf "%5.5\n" "1234567890"
will print 12345 . How do I get it to print
67890
Essentially, I just want the last 5 characters rather than the first 5.
num="1234567890"
printf "%d\n" ${num: -5}
This works for numbers. Use %s format specifier for characters:
$ var="ABCDEFGHIJK"
$ printf "%5s\n" ${var:5}
FGHIJK
or
$ printf "%5s\n" ${var: -3}
IJK
Thanks!
num="1234567890"
echo "${num#?????}"