Score:-3

cut even lines and merge to upper line

eg flag

I have a file like with CRLF line terminators:

Green Day: Rock Band Xbox 360
3074
Green Hell Steam
27015-27030, 27036-27037
Green Hell Switch
6667, 12400, 28910, 29900, 29901, 29920
Adios Steam

Adios Xbox One

Adore Playstation 4
3074, 3478-3479

It also have some empty line in even lines. How can I cut even lines and append to its upper line? like this: (comma after first line is necessary)

first line, second line

Green Day: Rock Band Xbox 360, 3074
Green Hell Steam, 27015-27030, 27036-27037
Green Hell Switch, 6667, 12400, 28910, 29900, 29901, 29920
Adios Steam,
Adios Xbox One,
Adore Playstation 4, 3074, 3478-3479
cn flag
https://stackoverflow.com/questions/9605232/how-to-merge-every-two-lines-into-one-from-the-command-line has a couple of methodes `paste` is pretty neat.
terdon avatar
cn flag
Wait, there are empty lines? That changes everything. Are they in the same file? Can you show us the full file? Will the empty lines change the line numbering? Can we still assume you want to only cut even lines and not odd ones?
masoud hanifehzadeh avatar
eg flag
yes there are some empty lines in the same file, but it doesn't change the order of lines. Only even lines can be empty.
terdon avatar
cn flag
Have you ever opened the file in Windows? Can it have Windows line endings?
masoud hanifehzadeh avatar
eg flag
Yes, result: filename: Unicode text, UTF-8 text, with CRLF line terminators
terdon avatar
cn flag
Please edit that into your question, it is essential information and is why the solutions you have been given don't work for you.
Score:1
tn flag

With :

first, pass your input file in dos2unix utility to remove windows line ending \r.

$ awk 'NR%2{printf "%s, ", $0;next}1' file
Green Day: Rock Band Xbox 360, 3074
Green Hell Steam, 27015-27030, 27036-27037
Green Hell Switch, 6667, 12400, 28910, 29900, 29901, 29920
Adios Steam, 
Adios Xbox One, 
Adore Playstation 4, 3074, 3478-3479
masoud hanifehzadeh avatar
eg flag
It didn't work. It only added a comma in front of even lines.
Gilles Quenot avatar
tn flag
Please, stop changing input since you have answers. Edited my post. Anything wrong?
masoud hanifehzadeh avatar
eg flag
Now I have: firstline[nextline] comma [space] secondline.
Gilles Quenot avatar
tn flag
I have exactly the expected output from your original question
masoud hanifehzadeh avatar
eg flag
filename: Unicode text, UTF-8 text, with CRLF line terminators I think because it has been edited in Windows it doesn't work for me. But I don't know how to fix this issue.
Gilles Quenot avatar
tn flag
Added mention of `dos2unix` tool
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.