For diverse reasons I'd like sometimes to have a string with newlines in a shell variable. For example, I could keep some short scripts (like FTP commands) built during the runtime of my script and simply feed them to the "ftp" command like:
Code:
echo "$script" | ftp -n ftp.myhost.pl
That is the theory, the practical problem is that executing "echo $script" strips the $script variable of all the newlines.
Of course I could use "\n"-s and execute "echo" with an "-e" parameter in this case. Sometimes however I'd like to do some more processing on the variable but and one execution of "echo" feeds it correctly but also strips it of all the "\n"-s and the next time becomes a bit tricky.
Is there some alternative to "echo" I could use to pass variables to streams that would preserve the original newlines?