Re: $\n doesn't get expanded between double-quotes
From:
Dave B
Subject:
Re: $\n doesn't get expanded between double-quotes
Date:
Fri, 3 Jul 2009 18:01:12 +0100
User-agent:
KMail/1.9.10
On Friday 03 July 2009, Richard Neill wrote:
> > X=$'a\nb c'
>
> This is still a missing feature: how to embed newlines in double-quoted
> bash string assignment:
>
> For example, if I want to write:
>
> EMAIL_BODY="Dear $NAME,$'\n\n'Here are the log-files for
> $(date)$'\n\n'Regards,$'\n\n'$SENDER"
>
> then this doesn't work. There are ways around it, such as:
> - building up the string in pieces or
> - EMAIL_BODY=$(echo -e "$EMAIL_BODY")
>
> but it's really ugly to do.
Maybe I'm missing something, but what's wrong with
EMAIL_BODY="Dear $NAME,
Here are the log files etc."
?
--
D.