Concatenate 2 rows into 1 row

I need to search a file for two values (valueA & valueB). ValueA will be on a different row than valueB, and concatenate the two together on the same row of my output.

Example: search input file for strings "node" and "OS", combine the two results into one row

input
node A
text
text
OS B
text
node AA
text
text
OS BB

Disired output

node A OS B
node AA OS BB

thanks!!!!

im sure there is better way to do this but this is what i came up with

grep '^(nod|OS)' filename | sed '$!N;s/\n/ /'

[im using windows, parentheses dont seem to work]

Use egrep

egrep '^(nod|OS)' filename | sed '$!N;s/\n/ /'

Here's another way, using awk...

awk '/node/ {printf("%s ",$0)} /OS/ {printf("%s\n",$0)}' filename

Cheers
ZB

thanks for the tip.. i am using cygwin now . it looks like unix.

Thanks Zazzybob....it worked perfectly!!!

Good day mate