I have a very long text file with the data repeated like this
510068893
510069716
620087756
510068729
620089710
560034147
510069875
M
M
M
M
M
M
M
1957
5/2/1980
1960
1978
5/8/1988
1984
1981
ABASSI FADHIL KHAMIS
ABDALLA HAMAD JUMA
ABDALLA ALI MAHADHI
ABDALLA ALI MFAKI
ABDALLA HAMAD KHAMIS
ABDALLA JUMA ALI
ABDALLA JUMA MABROUK
Sokoni
Sokoni
Sokoni
Sokoni
Sokoni
Sokoni
Sokoni
510068695
510068680
620086828
560034266
620088288
560033477
510068873
M
M
M
M
M
M
M
5/10/1983
1985
1937
1951
1974
14/5/1984
1987
ABDALLA KHAMIS ALI
ABDALLA KHAMIS HAMAD
ABDALLA KHAMIS USHURU
ABDALLA MOHAMMED JUMA
ABDALLA MOHAMMED SALEH
ABDALLA OMAR ABEID
ABDALLA OMAR NUHU
Sokoni
Sokoni
Sokoni
Sokoni
Sokoni
Sokoni
Sokoni
I want to join every first line of each group to form one line and repeat for every second line of each group until I finish. How can I do that using Vim or Perl Script.
The output should look like
510068893, M, 1957, ABASSI FADHIL KHAMIS, Sokoni 510069716, M, 5/2/1980, ABDALLA HAMAD JUMA, Sokoni
620087756, M, 1960, ABDALLA ALI MAHADHI, Sokoni 510068729, M, 1978, ABDALLA ALI MFAKI, Sokoni
etc.
sed '/./{:1;N;/\n./s/\s*\n/ /;t1}' very.long.text.file
?