bash - How to merge every two lines into one from the command line? -


i have text file following format. first line "key" , second line "value".

key 4048:1736 string 3 key 0:1772 string 1 key 4192:1349 string 1 key 7329:2407 string 2 key 0:1774 string 1 

i need value in same line of key. output should this...

key 4048:1736 string 3 key 0:1772 string 1 key 4192:1349 string 1 key 7329:2407 string 2 key 0:1774 string 1 

it better if use delimiter $ or ,:

key 4048:1736 string , 3 

how merge 2 lines one?

awk:

awk 'nr%2{printf "%s ",$0;next;}1' yourfile 

note, there empty line @ end of output.

sed:

sed 'n;s/\n/ /' yourfile 

Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -