formatting bash in linux - printf align middle

bash, printf

Solution

A bit tricky ... but what about this? ;)

STR="eeeeeee"; printf 'ddd %11s%-11s dddd \n' `echo $STR | cut -c 1-$((${#STR}/2))` `echo $STR | cut -c $((${#STR}/2+1))-${#STR}`

Problem

This line of code: ``` printf 'ddd %-22s dddd \n' "eeeeeee" ``` Aligns to the left. What could I use to align it to centre like this: ``` ddd eeeeeee dddd ```

Original source