Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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)

share|improve this question
add comment

3 Answers

up vote 8 down vote accepted

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.

share|improve this answer
    
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
add comment

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

sed "s/^/  /"
share|improve this answer
add comment

I think you might need:

sed 's/$/\r/g'
share|improve this answer
    
No, I tried \r, \r\n - all with the same results –  Brent Jun 15 '09 at 17:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.