2

I have data similar to this

prop1: val
prop2: val
 val continued
 continued still
prop3: val

I want to turn it into

prop1: val
prop2: val val continued continued still
prop3: val

so that it is easier to filter the props I want. I can't think of a simple way to do this.

Any suggestions? using awk/sed/tr/whatever.

CharlesB
  • 80,832
  • 27
  • 184
  • 208
sharat87
  • 7,132
  • 11
  • 50
  • 78

2 Answers2

1

This answer to a related question showed me the way. In short:

sed ':a;N;$!ba;s/\n / /g' file.txt

Or if you're on BSD or OS X:

sed -e ':a' -e 'N' -e '$!ba' -e 's/\n / /g' file.txt

Click through on the link for a fairly thorough explanation of how this works.

Community
  • 1
  • 1
Jordan Running
  • 97,653
  • 15
  • 175
  • 173
0

formail -c does this if your input looks like email headers throughout.

tripleee
  • 158,107
  • 27
  • 234
  • 292
  • Yes, they are indeed email headers. Also, I don't have the `formail` command. While I can find out and install it, I'd prefer a solution without external dependencies. – sharat87 Oct 06 '11 at 10:22