if I have file named some_file, with content as follows:
first line
second line
third line
and inside script:
VAR1="first line\nsecond line\nthird line"
VAR2="`cat some_file`"
I expect VAR1 and VAR2 to be the same, but it is obviously not the case according to the sed:
sed "s/^a/${VAR1}/" some_another_file # this is OK
sed "s/^a/${VAR2}/" some_another_file # this fail with syntactic error
I suppose that newline representation is somehow different, but i can’t find any way how to make VAR2 equal to VAR1.
thanks in advance
Change VAR1 to:
Then test them:
Update:
To get sed to work, change VAR2 so that it has “\n”s instead of newline characters.