linux - How to remove line feed character in csv file using sed -


i have csv data file data in following structure:

abc^"a detail explaination"^cde^"another detail explaination"^date 

however due user input, details entered line breaks, , broke program. i'll need remove line breaks in between double quote "

i tried use sed command doesn't change it, command tried is:

sed -e :1 -e 's@\(".*\)\n\(.*"\)@\1\\2@;t1' file.csv > file_changed.csv 

the criteria i'm trying replace line breaks \n encapsulated in between 2 double quotes, format of csv.

anyone has idea what's wrong sed command? or there other better way achieve this?

edit

additional notes, can't remove line breaks i'll need keep @ end of line since csv file import purpose. need remove encapsulated within double quotes

sed ':cycle^j/^\([^"]*"[^"]*"\)*[^"]*"[^"]*$/ {n;s/\n//;b cycle^j}' file.csv > file_changed.csv 

on each line have number of open , close " + 1 ", add next line, remove line feed , retest. print resulting line , go next


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -