I'm using bash on Linux, and I'm trying to create a variable that
contains multiple lines of text. I want to then pass this variable as
a parameter to a function, which will create a file that contains
(among other things), the contents of this variable. So I have this:
TMPFILE=/tmp/bla
MYVAR=$(cat <<EOF1
hello
there
EOF1)
myfunc $TMPFILE $MYVAR
function myfunc
{
ed -s $1 <<EOF2
1i
first line
$2
.
w
q
EOF2
This code is supposed to pre-pend the lines "hello" and "there" to fileQuote:}
/tmp/bla. The problem is that MYVAR contains the string "hello there"
on one line.
I actually don't care about the variable part, I just want to pass
multiple lines of text from a here document into myfunc. I just
thought using a variable would be the easiest, but I'm open to
suggestions. I don't know Perl, so that's not an option for me.