Search code examples
textgrepline-breakstextwrangler

TextWrangler - replace every second line-break with comma


I have a text file containing only text lines like this:

abcdefg
2009
hijklmnop
2012

I want to replace every second line-break with a comma. So it should look like this:

abcdefg, 2009
hijklmnop, 2012

How can I do this in TextWrangler?


Solution

  • I've no idea what TextWrangler is but you haven't had an answer in about a day and you mention grep so maybe awk is an option to and if so it's trivially:

    $ awk '{ORS=(NR%2?", ":"\n")}1' file
    abcdefg, 2009
    hijklmnop, 2012