Reputation: 2158
How do I send an email, where "Hello world!" appears in the first line and "Test run" appears in the second line. I have tried \r\n and \n. Are there any way to stack the line after line?
echo "Hello world! \r\n Test run" | mail -s "Test" [email protected]
The email should be viewed like:
Hello world!
Test run
Upvotes: 0
Views: 1831
Reputation: 7507
If you want more than two or three lines, you can also use the following syntax:
mail -s "Test" [email protected] << EOF
then type your mail and finally a line with only EOF
in it; it will allow you to type text on several lines as a single "logical" command line. (Try to browse the history of your command line after that, you will understand what I mean by "one logical command line".
Upvotes: 1
Reputation: 96258
Use echo -e
. From the manual:
If the -e option is given, interpretation of the following backslash-escaped characters is enabled. [...]
# echo -e "Hello world! \r\n Test run"
Hello world!
Test run
In bash you can also use $'string'
:
Words of the form $'string' are treated specially. The word expands to string, with backslash-escaped characters replaced as specified by the ANSI C standard.
# echo $'Hello world! \r\n Test run'
Hello world!
Test run
Upvotes: 0