Search code examples
linuxbashoutlookmailx

mail bash variable on a new line


echo $d produces output below which is separated by new line after each ';'

REVOKE ALL ON URI 'hdfs://nameservice/data/ed_bos_reporting_stg' FROM ROLE ed_bos_reporting; 
REVOKE ALL ON URI 'hdfs://nameservice/data/fq' FROM ROLE ed_edw_telephony_rw; 
REVOKE ALL ON URI 'hdfs://nameservice/data/fq' FROM ROLE edw_rw; 
REVOKE ALL ON URI 'hdfs://nameservice/data/standard_register_mail_piece' FROM ROLE standard_register_mail_piece_rw; 
REVOKE ALL ON URI 'hdfs://nameservice/data/tenant/ed_edw/LSFE_CDC/target_files' FROM ROLE edw_rw; 
REVOKE ALL ON URI 'hdfs://nameservice/data/tenant/ed_standard_register_mail_piece_stg' FROM ROLE ed_standard_register_mail_piece_rw;

When I pipe $d in the mail command -

echo "$d" | mail -s "subject" -r "Name<[email protected] >" [email protected]

The results are not separated by a new line.

I have tried:

echo -e "$d\n" | mail -s "subject" -r "Name<[email protected] >"
echo -e "$d" $'\n' | mail -s "subject" -r "Name<[email protected] >"

And few others with no luck. Any suggestions/leads to documentation would be appreciated.

UPDATE This does work fine in gmail. However not in Outlook


Solution

  • It seems that Outlook removed extra line breaks from my message. I was able to use awk to fix the problem.

    echo "$d" | awk '{ print $0"   " }' | mail -s "subject" -r "Name<[email protected] >" [email protected]
    

    This reads every single line, and re-prints it with three spaces at the end. Outlook is now happy. https://blog.dhampir.no/content/outlook-removes-extra-line-breaks-from-plain-text-emails-how-to-stop-it