I need to remove all text between two given strings in a text file. The strings may be located on different lines. For instance, in the following text file
@article{ginsberg_lifespan_2018,
title = {On the lifespan of three-dimensional abstract gravity water waves with vorticity},
abstract = {test1
test2 abstract {NS}
test3},
language = {en},
urldate = {2018-12-05},
author = {Ginsberg, Daniel},
month = dec,
year = {2018}
}
@article{higaki_two-dimensional_2017,
title = {On the two-dimensional steady {Navier}-{Stokes} equations related to flows around a rotating obstacle},
abstract = {We study the two-dimensional stationary Navier-Stokes equations with rotating effect in the whole space. The unique existence and the asymptotics of solutions are obtained without the smallness assumption on the rotation parameter.},
journal = {arXiv:1703.07372 [math]},
author = {Higaki, Mitsuo and Maekawa, Yasunori and Nakahara, Yuu},
month = mar,
year = {2017},
note = {arXiv: 1703.07372},
keywords = {Mathematics - Analysis of PDEs}
}
I want to remove everything between abstract =
and a },
which is always at the end of a line, including these strings. That is I want the following output:
@article{ginsberg_lifespan_2018,
title = {On the lifespan of three-dimensional abstract gravity water waves with vorticity},
language = {en},
urldate = {2018-12-05},
author = {Ginsberg, Daniel},
month = dec,
year = {2018}
}
@article{higaki_two-dimensional_2017,
title = {On the two-dimensional steady {Navier}-{Stokes} equations related to flows around a rotating obstacle},
journal = {arXiv:1703.07372 [math]},
author = {Higaki, Mitsuo and Maekawa, Yasunori and Nakahara, Yuu},
month = mar,
year = {2017},
note = {arXiv: 1703.07372},
keywords = {Mathematics - Analysis of PDEs}
}
I know this kind of questions were already asked and I tried the posted solutions. For example, I used
perl -0777 -pe 's/abstract = .*},\n/\n/gs'
but this removes the text between the first occurence of abstract =
and the last occurence of },
, not consecutive occurences. That is I get
@article{ginsberg_lifespan_2018,
title = {On the lifespan of three-dimensional gravity water waves with vorticity},
keywords = {Mathematics - Analysis of PDEs}
}
How can I correct this command to obtain the desired result?
sed '/abstract/,/\}/d' yourfile
journal
line in the output.