Discussion:
[Help-bash] loading a file into a variable using cat
Lakshman Siddardha
2017-09-22 14:01:03 UTC
Permalink
file:list
----------------------------------------
hello
world
----------------------------------------

when i type on terminal the following command:
$ cat $file

it displays as it is in file
----------------------------------------
hello
world
----------------------------------------

when i execute a shell script, it gives output in one line only
---------------------------------------
ex.sh
----------------------------------------
lista=$(cat list)
echo $lista
-------------------------------------

it gives output of
--------------------------
hello world
-------------------------

i want new line character between "hello" and "world"
Greg Wooledge
2017-09-22 14:37:35 UTC
Permalink
Post by Lakshman Siddardha
when i execute a shell script, it gives output in one line only
---------------------------------------
ex.sh
----------------------------------------
lista=$(cat list)
echo $lista
http://mywiki.wooledge.org/BashPitfalls#pf14
http://mywiki.wooledge.org/Quotes

Loading...