Q:

How to merge text having some content and leave blank lines

I have an address txt file on Ubuntu. Something like below -
Name
Address1
Address2
Address3

Name2
Address12
Address22
Address32

How can I merge the content as like -
Name Address1 Address2 Address3
Name2 Address12 Address22 Address32

Actually the addresses are written to a file one after another - like as mentioned above. A new address is separated by a new line or blank line. Now I want to merge for each address row into one line - and so repeatedly for all addresses

A:

Here is an awk
awk -v RS= '{$1=$1}1' file
Name Address1 Address2 Address3
Name2 Address12 Address22 Address32
Name3 Address13 Address23 Address33

By setting RS makes awk work with blocks of data as record.
{$1=$1}1 reconstruct the line.
This fail if field starting with 0 (so less robust):
awk -v RS= '$1=$1' file

A:

Setting RS to the empty string will use one or more blank lines as the record separator.
$ cat addr.txt
Name
Address1
Address2
Address3

Name2
Address12
Address22
Address32

Name3
Address13
Address23
Address33

$ awk 'BEGIN { RS="" } { gsub("\n"," ") }1' addr.txt
Name Address1 Address2 Address3
Name2 Address12 Address22 Address32
Name3 Address13 Address23 Address33

From the awk user's guide:

RS == ""
Records are separated by runs of blank lines. When FS is a single
  character, then the newline character always serves as a field
  separator, in addition to whatever value FS may have. Leading and
  trailing newlines in a file are ignored.

