Você pode experimentar o one-liner abaixo Perl.
perl -00pe 's/(\"(?:(?!\"|\|).)*)\n((?:(?!\"|\|).)*\")//g' file
Exemplo:
$ cat file
test \" data
get this line\" in above line
test \" data
keep| this line\" here
$ perl -00pe 's/(\"(?:(?!\"|\|).)*)\n((?:(?!\"|\|).)*\")//g' file
test \" dataget this line\" in above line
test \" data
keep| this line\" here
Explicação:
( group and capture to :
\ '\'
" '"'
(?: group, but do not capture (0 or more
times):
(?! look ahead to see if there is not:
\ '\'
" '"'
| OR
\| '|'
) end of look-ahead
. any character except \n
)* end of grouping
) end of
\n '\n' (newline)
( group and capture to :
(?: group, but do not capture (0 or more
times):
(?! look ahead to see if there is not:
\ '\'
" '"'
| OR
\| '|'
) end of look-ahead
. any character except \n
)* end of grouping
\ '\'
" '"'
) end of