EDIT: Thank you all for answering the question, all the answers work. Stack Overflow indeed has a great community.
Receiving a flat file as a source. In one of the fields, the value is segregated into new lines, but there is a need to break the newline and combine it into a single content.
Ex: File is as below:
PO,MISC,yes,"This
is
an
example"
PO,MISC,yes,"This
is
another
example"
In the above ex, the data is being read as 9 lines, but we need the input to be read as a single line, as shown below -
PO, MISC, yes, "This is an example"
PO, MISC, yes, "This is another example"
Tried via the below syntax but did not succeed. Is there any way to achieve this? I also need to print the file contents into another file.
Syntax:
awk -v RS='([^,]+\\,){4}[^,]+\n' '{gsub(/\n/,"",RT); print RT}' sample_attachments.csv > test.csv