Find the answer to your Linux question:
Results 1 to 2 of 2
Hello, i added some message into variable where i have empty lines to keep formatting. then im outputting the variable in echo and also sending it as an email message. ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Linux User postcd's Avatar
    Join Date
    Apr 2011
    Posts
    325

    Bash: How to save echo text into variable and keep empty lines?


    Hello,

    i added some message into variable where i have empty lines to keep formatting.

    then im outputting the variable in echo and also sending it as an email message.

    But this email contains no empty lines..


    message="This is a message. Line 1

    Line2

    Line3"

    echo $message
    echo $message | mail -s "mysubject" mymail@gmail.com
    pls any idea how to do, and preserve lines in email?

  2. #2
    Linux Newbie
    Join Date
    Nov 2012
    Posts
    224
    Use More Quotes:
    Code:
    echo "$message" | mail...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •