How to store output from printf with formatting in a variable? [duplicate]
问题 This question already has answers here : I just assigned a variable, but echo $variable shows something else (7 answers) Closed 4 years ago . I would like to store the output of printf with formatting in a variable, but it strips off the formatting for some reason. This is the correct output $ printf "%-40s %8s %9s %7s" "File system" "Free" "Refquota" "Free %" File system Free Refquota Free And now the formatting is gone $ A=$(printf "%-40s %8s %9s %7s" "File system" "Free" "Refquota" "Free %