I need my script to send an email from terminal. Based on what I\'ve seen here and many other places online, I formatted it like this:
Here is a flexible way to do deal with multiple indented lines without using heredoc.
echo 'Hello!'
sed -e 's:^\s*::' < <(echo '
Some indented text here.
Some indented text here.
')
if [[ true ]]; then
sed -e 's:^\s\{4,4\}::' < <(echo '
Some indented text here.
Some extra indented text here.
Some indented text here.
')
fi
Some notes on this solution:
\
or replace the string delimiters with double quotes. In the latter case, be careful that construction like $(command)
will be interpreted. If the string contains both simple and double quotes, you'll have to escape at least of kind.