How can I assign the output of a function to a variable even if said output contains only a single line feed ($'n') ?
For example, the following prints '' but I would expect it to print $'n'.
my_var="$(printf 'n')"
printf '%q' "$my_var"
So my question is how can I get my_var to contain the line feed?
I don’t understand why this:
printf '%q' "$(printf 'n')"
doesn’t give the same output as this:
printf '%q' $'n'