Parsing a file in bash

Hello All,
I have the following input file that i'm trying to parse:

10.0.011.40
hadoop 15526 15524 0
hadoop 15528 15526 0
hadoop 19747 4018 1
10.0.081.227
hadoop 2862 2861 0
hadoop 2864 2862 0
hadoop 12177 14376 1

I'm trying to get this in my output file:

10.0.011.40 15526 15528 19747
10.0.081.227 2862 2864 12177

I have tried this code:

#!/usr/bin/bash
#set -x
while read line
do
  if [[ $line =~ ^[0-9] ]];then
    IPADDR=`echo "$line" | awk --posix '{if ($1 ~ /^[0-9]/) print $1}'`
  else
    PID=`echo "$line" | awk '{ print $2 }'`
  fi
  IPADDR+=($PID)
  echo ${IPADDR[@]} > ex2
done < ex1

The problem;
I have more than 1 PID rows ( hadoop rows, for each server)

You could do it using awk alone:

awk '
        /^[0-9]/ {
                ip = $1
                next
        }
        !/^[0-9]/ {
                A[ip] = A[ip] ? A[ip] FS $2 : $2
        }
        END {
                for ( k in A )
                        print k, A[k]
        }
' ex1

Try :

if you have gawk, if pattern is ip address...

awk --re-interval '
/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/{
	if(p)print ""
	printf("%s%s",$0,OFS)
	next
}
{
	printf $2 OFS
	p=1
}
END{
	print ""
}'

or just this if assumption is numeric char

awk  '
/^[0-9]/{
	if(p)print ""
	printf("%s%s",$0,OFS)
	next
}
{
	printf $2 OFS
	p=1
}
END{
	print ""
}' file