2

I have a script that emails certain linux log entries to me, and I read the email in MS Outlook.

The problem is that all the lines run together with no linefeeds between the lines.

To address this I inserted sed "s/$/\n/" before the mail command, but that gives me 2 linefeeds between each line in the email!

What is the proper way to get a single linefeed between each line (using sed)

Brent
  • 22,219
  • 19
  • 68
  • 102

3 Answers3

8

Check to make sure your Outlook isn't helpfully removing line breaks for you (ie the problem isn't Linux, it's Outlook). By default I think it does. It should be telling you this at the top of the view panel.

David Mackintosh
  • 14,223
  • 6
  • 46
  • 77
  • Indeed, this is it (I should learn to read better). Thanks a bunch! – Brent Jun 15 '09 at 17:14
  • Any idea why Outlook thinks these are "Extra" line breaks? It removes ALL OF THEM! – Brent Jun 15 '09 at 17:15
  • It is trying to helpfully line-wrap so that lines that were made in an older mail client where formatting was done explicitly and not through indirect markup tags take advantage of your million-character-wide message view pane. – David Mackintosh Jun 15 '09 at 18:17
5

If you add 2 spaces to the beginning of each line, Outlook will not remove the linefeeds.

sed "s/^/  /"
Brent
  • 22,219
  • 19
  • 68
  • 102
1

I think you might need:

sed 's/$/\r/g'
Kyle Brandt
  • 82,107
  • 71
  • 302
  • 444