new line characters not preserved in bash
I have a bash scripting question. When I assign the output of a command to a variable:
export blah="$(ls -l)"
Then print the contents of blah:
echo $blah
the new line characters in ls -l's output is not preserved.
otal 106 dr-xr-xr-x. 2 root root 4096 Oct 5 03:18 bin dr-xr-xr-x. 5 root root 1024 Aug 24 09:12 boot -rw-r--r--. 1 root root 215 Aug 25 09:21 chart.txt drwxr-xr-x. 20 root root 4200 Oct 6 08:10 dev drwxr-xr-x. 127
I need the command's columns to remain in tact, a new line after each row ends. How can I save the newline characters in a command's output?
Thanks.
Thanks
|