You can truncate strings with a printf field-width specifier:
printf
printf(\"%.5s\", \"abcdefgh\"); > abcde
Unfortunately it does no
Example from Bash command line:
localhost ~$ printf "%.3s\n" $(printf "%03d" 1234) 123 localhost ~$