in reply to printf syntax
Two ways:
You need to wrap the variable name in curlies to prevent the 's' being taken as a part of it:
$space = 5; printf "%${space}s\n", 'x';; x [download]
$space = 5; printf "%*s\n", $space, 'x';; x [download]