I have the following code
printf "%8s.%s\n" "$RANDOM" "$RANDOM" "$RANDOM" "$RANDOM" "$RANDOM" "$RANDOM" "$RANDOM" "$RANDOM"
That produces the expected output
24756.22971
9910.13045
7701.30924
22972.27622
I would like to save this output with leading spaces in a variable for later uses like this
printf -v output "%8s.%s\n" "$RANDOM" "$RANDOM" "$RANDOM" "$RANDOM" "$RANDOM" "$RANDOM" "$RANDOM" "$RANDOM"
However, if i try to print/echo the variable $output, leading spaces are gone:
24756.22971
9910.13045
7701.30924
22972.27622