My File is:
"abc"..,,xyz 123 "New york".."END" <- # Print this entire line as starts with " and ends with "END"
"mnh".....blahblah <- # dont print this line and hold til "END" is
"rew"..?/.."1324.75 United # found and once it is found, merge multi-
States"??..."END" # lines to single line without changes
Desired output:
"abc"..,,xyz 123 "New york".."END"
"mnh".....blahblah"rew"..?/.."1324.75 United States"??..."END"
Found the below sed which does everything with start_pattern as " and end_pattern as "END", but
it breaks when intermediate line starts with "; here when it starts with "rew", before the end_pattern is found.
sed -n '/^"/,/^"END"/{
//!{H;/{x;s/\n\([^\n]*\)$/\1/;x}};
/^"/{h};/"END"/{x;p};d
}' file
Link: How to remove newlines between data of each record which are located between 2 patterns?