Merging 2 lines based on a string

Dear Unix gurus

I need help with a command or script to merge 2 lines where ever we find the string.

I have attached scanned document.

First line has string value: VSIN, immediate line has value: SETTLEMENT

Where it finds the 2 string values in the whole file, one below the other, those 2 lines to be merged into a single line and the other detail data lines has to be remained in the same order.

E.g.:

Line1: VSIN .... (Space) SETTLEMENT CURRENCY ....
Line2: other detail data in the same order 
Line3: VJRE ...
Line4: VJRE ...
Line5: VSIN .... (Space) SETTLEMENT CURRENCY ....
Line6: VJRE ....
Line7: VJRE ....
Line8: VJRE...
Line9: VSIN. ...(Space) SETTLEMENT CURRENCY....
....
....

Many thanks
Your help is much appreciated as I am not a core Unix programmer.
Many thanks
Karunya

Hi what have you tried ? Also please post a sample input, rather than attach a picture..

Line1:vsin : vj005 Acc type : vjs
Line2:Settlement cur : USD trade date :22-01-12
Line3:vjre 15565  1 020765 S  30-01-14 12,000 Vets
Line4: vjre 12678  1 03765   B 30-01-14  2,000 vets
Line5: vsin : vj006 Acc type : cgf
Line6: vjre  1025   1 07654    S 30-01-14. 2,765 vets
..
..

---------- Post updated at 04:28 AM ---------- Previous update was at 04:26 AM ----------

Sorry line 6 is just like line 2 which starts with
Line6: Settlement curr ...
[/CODE]

Well, that's sort of sample input, more or less. What about scrutinizer's first question?

Googled for the command to get solution and I am not able find one. Your help is much appreciated.

OK. Try

sed '/^VSIN/ {N; s/\n/ /}' file

or

awk '/^VSIN/ {getline X; $0=$0 " " X}1' file

Please be aware that this assumes that line1: etc. is added by you and not in the file.

---------- Post updated at 14:33 ---------- Previous update was at 14:32 ----------

AND it is NOT clear if vsin is upper or lower case...

cat file
VSIN .... (Space)
SETTLEMENT CURRENCY ....
other detail data in the same order 
VJRE ...
VJRE ...
VSIN .... (Space)
SETTLEMENT CURRENCY ....
VJRE ....
VJRE ....
VJRE...
VSIN. ...(Space)
SETTLEMENT CURRENCY....

awk '/VSIN/ {getline X; $0=$0 " " X}1' file
VSIN .... (Space) SETTLEMENT CURRENCY ....
other detail data in the same order 
VJRE ...
VJRE ...
VSIN .... (Space) SETTLEMENT CURRENCY ....
VJRE ....
VJRE ....
VJRE...
VSIN. ...(Space) SETTLEMENT CURRENCY....

sed '/VSIN/ {N; s/\n/ /}' file
VSIN .... (Space) SETTLEMENT CURRENCY ....
other detail data in the same order 
VJRE ...
VJRE ...
VSIN .... (Space) SETTLEMENT CURRENCY ....
VJRE ....
VJRE ....
VJRE...
VSIN. ...(Space) SETTLEMENT CURRENCY....

To sensibly continue the discussion, please post your OS, shell, sed/awk version, and (part of) the unmodified input file.

Hi RudiC

I understood the issue now.
From the source file, end of the VSIN word line doesn't have space in it.
I tried your commands and it worked with the word (Space)

Please there is no (space) string in source file.
What I tried to mention was in the output I need a space between 2 lines after merging

Apologies if I confused you

---------- Post updated at 04:51 AM ---------- Previous update was at 04:47 AM ----------

Can you please modify the command

Thanks RudiC