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 %")
$ echo $A
File system Free Refquota Free %
echo
will print each of it's arguments in order, separated by one space. You are passing a bunch of different arguments to echo
.
The simple solution is to quote $A
:
A=$(printf "%-40s %8s %9s %7s" "File system" "Free" "Refquota" "Free %")
echo "$A"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With