I'm on the latest version of macOS with bash 5.0 installed. I'm trying to write a bash script that will write out a multiple-line text document using variables & the echo program.
I have tried adding a newline character (\n) at multiple different places in the script, but I can't seem to get that to work.
text=(
lineOne
lineTwo
lineThree
)
echo "${text[@]}" >> text.txt
I'm thinking that I should be able to, using the echo program, output a file with multiple lines, since, when you remove the variables and just run echo on its own, it will create new lines automatically. In my case what I'm getting is:
lineOne lineTwo lineThree
What I'm hoping for is:
lineOne
lineTwo
lineThree