I want to remove any non printable new line characters in the column data.
I have enclosed all the columns with double quotes to delete the new line characters present in the column easily and to ignore the record delimiter after each end of line.
Say,I have 4 columns seperated by comma and enclosed by quotes in a text file. I'm trying to remove \n and \r characters only if it is present in between the double quotes
Currently used trim,but it deleted every line break and made it a sequence file without any record seperator.
tr -d '\n\r' < in.txt > out.txt
Sample data:
"1","test\n
Sample","data","col4"\n
"2\n
","Test","Sample","data" \n
"3","Sam\n
ple","te\n
st","data"\n
Expected Output:
"1","testSample","data","col4"\n
"2","Test","Sample","data" \n
"3","Sample","test","data"\n
Any suggestions ? Thanks in advance