column data to rows every n line

Hi every one,

I am trying to organise an input text file like:

input
1 2 3 4 5
6 7 8
9 10
11 12 13 14 15
16 17 18 
19 20
 
into an output as following:

output file
 
1 2 3 4 5 6 7 8 9 10
11 12 13 14 15 16 17 18 19 20
 
In fact, the output will have 10 fields and two rows. I have tried the following AWK:
 
awk ' NR%3==0 {print (tr '\n ' ' )}' input>output
 

but it does not work!

Any help would be very much appreciated.

nawk 'ORS=(FNR%3)?FS:RS' myFile

Amazing result on Solaris!! But it does not work on Sun, complaining nawk not found?! Any clue?

I don't quite understand the above....
Try 'awk' or '/usr/xpg4/bin/awk' or 'gawk' (if you have one).

Thank you so much! gawk works on Sun systems

$ xargs -n10 -a urfile
1 2 3 4 5 6 7 8 9 10
11 12 13 14 15 16 17 18 19 20