sed append "\n" to end of every line in file

I know it sounds simple, but I want to e-mail the last 6 lines of a log file, which I have tailed into logresults.txt. I'm using

echo -e "Subject:server results\nFrom:server log <user@domain.com>\n"`cat logresults.txt` | sendmail -t user@domain.com

which works, but the body of the e-mail has no carriage returns, though the logresults.txt does. If I use sed to add \n to the end of logresults.txt, it just generates a line break in logresults.txt, which gives me the same results.

Is there a way I can append \n to the end of each line in logresults.txt so that actually gets piped to sendmail? I.e. append "\n" to then end of logresults.txt?

Try to ad a CR (convert the text to DOS format):

awk '
BEGIN{print "Subject:server results\nFrom:server log <user@domain.com>"}
{printf("%s\015\n", $0)}
' logresults.txt | sendmail -t user@domain.com
{
 printf 'Subject: server results\nFrom: server log <user@example.com>\n'
 cat logresults.txt
} | sendmail -t user@example.com

beautiful, THANKS! Awk is my new best friend :slight_smile: (now I have to man up on it to see what other goodies I can use it for :slight_smile: ) Where would a awk n00b start the journey to enlightenment?

Gawk: Effective AWK Programming - GNU Project - Free Software Foundation (FSF)

But awk is massive overkill for the task above.