tags:

views:

11

answers:

2

vCard lines can be folded by inserting "\r\n " (that's a space at the start of the new line), but I'm struggling to unfold them with the line-oriented GNU tools (sed, cut). Any ideas? Effectively, from the string

foo
 bar
baz
ban
 bay
 bal

it must return

foobar
baz
banbaybal
A: 
$ awk '{s=s" "$0}END{gsub("  +","",s);gsub(" ","\n",s);print s}' file

foobar
baz
banbaybal
ghostdog74
How do I get rid of the empty line at the beginning? I have to distinguish it from other empty lines in the input.
l0b0
A: 

Found a solution: sed -n '1h;1!H;${;g;s/\r\n //g;p}' (DOS newline mode).

l0b0