mdcq
mdcq

Reputation: 2026

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?

Upvotes: 0

Views: 924

Answers (1)

Ed Morton
Ed Morton

Reputation: 204218

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

Upvotes: 2

Related Questions