Want to add trailing spaces to the variable

I want to keep string/varible length to 10 even its actual length is less than 10(may be no value). so, i want to add trailing spaces to my string. :wall:
"typeset -L10 myvarible" is not working, its saying invalid typset -L option.
Can you please advise.

myvar="123"
myvar=$(printf "%-10s" $myvar)
echo ":$myvar:"

Jim, Thank you. that worked like a charm.:b:

---------- Post updated 07-10-12 at 09:52 AM ---------- Previous update was 07-09-12 at 09:36 PM ----------

Jim, i got into another issue when iam using above code.
it is behaving weared when i had space in $myvar value.

myvar="12 123"
myvar=$(printf "%-10s" $myvar)
echo ":$myvar:"

result is coming -> "

:12 123 :

"

but i want -> "

:12 123:

" can you please help me out.
Thanks.

---------- Post updated at 11:47 AM ---------- Previous update was at 09:52 AM ----------

Jim, i got into another issue when iam using above code.
it is behaving weared when i had space in $myvar value.

myvar="12 123"
myvar=$(printf "%-10s" $myvar)
echo ":$myvar:"

result is coming -> "

:12(8 spaces)123(7 spaces):

"

but i want -> "

:12 123(4spaces):

" can you please help me out.
Thanks.

printf is padding two arguments (neither of which contains any spaces) because the shell is splitting the unquoted expansion of $myvar. Double quote your variable.

Regards,
Alister

That worked. Thank you. :b: