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
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.
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 ?
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{}