I'm using msmtp to create e-mail alerts on some RPi kiosks we have set up at my company, and unfortunately if I try to include the last 5 lines of a log file in the e-mail alert, msmtp doesn't handle the line breaks correctly and it prints all on a single line of text. If \n is included in each line in the log file, it outputs correctly in the e-mail alert.
A basic example for this command would be:
echo -e "This is a test. $(tail -5 /var/log/syslog)" | msmtp @domain
which does echo the syslog; yet it's all in one wall of text because msmtp
doesn't seem to handle line breaks. If I manually edit the syslog and add \n
to the end of each line, it prints properly
What's the proper syntax for sed or awk to add \n
to the end of every line in a log file?
\n
literally (i.e. a backslash and a newline), or another newline character, or something else, perhaps a carriage return (often presented as\r
)? The newline is what you already have in the log file, in any unix text file at the end of each and every line, so adding another one doesn't seem like something that should be needed.