Perhaps a little surprisingly, paste
is a good way to do this:
paste -s -d","
This won’t deal with the empty lines you mentioned. For that, pipe your text through grep
, first:
grep -v '^$' | paste -s -d"," -
Perhaps a little surprisingly, paste
is a good way to do this:
paste -s -d","
This won’t deal with the empty lines you mentioned. For that, pipe your text through grep
, first:
grep -v '^$' | paste -s -d"," -