I am trying to right-align coloured text with a given field width.
Based on right text align - bash and Using colors with printf I don't understand the output of:
blue=$(tput setaf 4)
normal=$(tput sgr0)
printf "%4s\n" "${blue}aaa${normal}"
blue=$(tput setaf 4)
normal=$(tput sgr0)
printf "%10s\n" "${blue}aaa${normal}"
blue=$(tput setaf 4)
normal=$(tput sgr0)
printf "%40s\n" "${blue}aaa${normal}"
blue=$(tput setaf 4)
normal=$(tput sgr0)
printf "%8s\n" "${blue}aaa${normal}"
which is:
aaa
aaa
aaa
aaa
why are entries 1,2 and 4 left-aligned?
Thanks!
GNU bash, version 4.4.23(1)-release (x86_64-redhat-linux-gnu)