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
  • 86,532
  • 28
  • 194
  • 218
sharat87
  • 7,330
  • 12
  • 55
  • 80

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
  • 102,619
  • 17
  • 182
  • 182
0

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

tripleee
  • 175,061
  • 34
  • 275
  • 318
  • 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