Richard Neill wrote: > 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.
A variant of the traditional idiom for this works fine: TAB=$'\t' NL=$'\n' and using $TAB and $NL appropriately within the double-quoted string. (The traditional idiom drops the $ and uses literal tabs and newlines between single quotes.) Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer Chet Ramey, ITS, CWRU c...@case.edu http://cnswww.cns.cwru.edu/~chet/