Bash to merge 2 consecutive lines in a file

bash, command-line, linux

Solution

Using `sed`:

sed '$!N;s/\n/,/' filename

Using `paste`:

paste -d, - - < filename

`paste` would leave a trailing `,` in case the input has an odd number of lines.

Problem

I want convert this text on a given file: ``` 87665 S 3243423 S 334243 N ... ``` to something like this: ``` 87665,S 3243423,S 334243,N ... ``` I've been reading some similar questions, but it didn't work... is there a way to do this with a single line command in linux? Thanks!

Original source