Remove newline character or join the broken record

Hi,
I have a very huge file, around 1GB of data.
I want to remove the newline characters in the file but not preceded by the original end delimiter {}
sample data will look like this

1[|]2[|]3[|]4[|]5[|]6[|]7
[|]a[|]b[|]c[|]d{}
1[|]2[|]3[|]4[|]sss[|]ss
as6[|]7
[|]a[|]b[|]c[|]d{}
1[|]2[|]dsad3[|]dad
4[|]sdad5[|]6[|]7
[|]a[|]b[|dsad]c[|]dsadd{}

this should look like this

1[|]2[|]3[|]4[|]5[|]6[|]7[|]a[|]b[|]c[|]d{}
1[|]2[|]3[|]4[|]sss[|]ssas6[|]7[|]a[|]b[|]c[|]d{}
1[|]2[|]dsad3[|]dad4[|]sdad5[|]6[|]7[|]a[|]b[|dsad]c[|]dsadd{}

i tried the below perl command, since the file is too huge it is throwing an error

perl -0lne 's/\n//g;print "$1\n" while /(.*?{})/g' sourcefile

error

Substitution loop at -e line 1, <> chunk 1.

sed command will be better which will remove all the '\n' but not '{}\n'
Please hlp me with any clue's

Hi

awk '/{}$/{print;next}{printf $0;}' file

Guru.

awk ' 
{ a = a $0 }
/\{\}$/ { print a; a = ""; next }' FILE

Thanks Yazu... It Worked...

---------- Post updated at 03:22 AM ---------- Previous update was at 03:20 AM ----------

@guruprasadpr
It worked till some line. and then thrown an error like below

awk: cmd. line:1: (FILENAME=xaa FNR=16518) fatal: not enough arguments to satisfy format string
        `Some record{}'
                                                                                                                                                                                                                                                                                                                                                   ^ ran out for this one

try like this

# awk '/{}$/{print;next}{printf "%s",$0;}' file

and 2.solution

# awk -vFx='{}' '{if(substr($0,length-1,length)!=Fx)a=a $0;else {a=a $0;print a;a=""}}' file

regards
ygemici

I have removed the next statement and trying to understand how the code works.. below i have given i how i have understood this code. please correct me if i am wrong.

bash-3.00# awk '/{}$/{print}{printf "%s ",$0;}' test.txt

1[|]2[|]3[|]4[|]5[|]6[|]7 [|]a[|]b[|]c[|]d{}
[|]a[|]b[|]c[|]d{} 1[|]2[|]3[|]4[|]sss[|]ss as6[|]7 [|]a[|]b[|]c[|]d{}
[|]a[|]b[|]c[|]d{} 1[|]2[|]dsad3[|]dad 4[|]sdad5[|]6[|]7 [|]a[|]b[|dsad]c[|]dsadd{}
[|]a[|]b[|dsad]c[|]dsadd{} 

so here the pattern statement is /{}$/
the action statement is {print} ( This print statement will execute if the pattern matched successfully. else this wont executed )
{printf "%s ",$0;} ( This statement will execute throught the script. it doesnt come under any condition )

line 1 : 1[|]2[|]3[|]4[|]5[|]6[|]7

the pattern {}$ doesnt match this line so the {print} statement doesnt execute.
But the {printf "%s ",$0;} executes and prints the same line1 as thats the current record in processing.

Now the first line has been read and awk moves on to the next line

line 2 : [|]a[|]b[|]c[|]d{}

the pattern {}$ does match and {print} statement gets executed.

Now awk should again print the line 2 as there is {printf "%s ",$0;} right ? how does it move to next record ?

# awk '/{}$/{print}{printf "%s ",$0;}'

first execute [1.LINE]
/{}$/ [ you can think there is a `if` ] the pattern matched successfully then print (with default ORS="\n")
result --> NULL (because 1.line does not match with '{}$')
[ you can think there is an `else` ] print "without newline" (printf ..)
result --> "1[|]2[|]3[|]4[|]5[|]6[|]7 "

second execute [2.LINE]
/{}$/ pattern match then print
result -->[|]a[|]b[|]c[|]d{}

lastresut
"1[|]2[|]3[|]4[|]5[|]6[|]7 "[|]a[|]b[|]c[|]d{}
.............

so it goes on like this..

regards
ygemici