Selecting section and removing match

I have a file with contents as shown in file.texi

Would like to keep only the sections that have inlineifset till the empty line is reached. Finally replace the
following string with a space

@inlineifset{mrg, @opar{@bullet{} 

I had written the following command but it messed my file

sed 's/inlineifset/,/^ *$/p' $flnm |\
  sed 's/@inlineifset\{mrg\, @opar\{@bullet\{\} //g' > ch--outline.texi

The result should be

@subsubsection ObsPy LibmSeed License Problem,,,,}}

@inlineifset{mrg, @opar{@point{} ObsPy [LibmSeed];, Problems Merging
Codes;, Hard to package and release software;, Practices in Seismology
require careful thought,}}

@inlineifset{mrg, @opar{@point{} ObsPy [LibmSeed];, Problems Merging
Codes;, Hard to package and release software;, Practices in Seismology
require careful thought,}}

@inlineifset{mrg, @opar{+ ObsPy LibmSeed Routines;, libmseed-2.6.2:
obspy-readbuffer.c packdata.c unpackdata.c;, Pack Routines taken from
qlib2;, Incompatible Licenses.,}}

cat file.texi

@node ObsPy--ObsPy--LibmSeed--LicProblem
@subsubsection ObsPy LibmSeed License Problem

@inlineifset{mrg, @opar{@bullet{} @subsubsection ObsPy LibmSeed License Problem,,,,}}

@inlineifset{mrg, @opar{@point{} ObsPy [LibmSeed];, Problems Merging
Codes;, Hard to package and release software;, Practices in Seismology
require careful thought,}}

The developers of ObsPy had taken a step in the right direction by
promoting principled, community minded seismological computations.
However, the @emph{LibmSeed} story exposes the problems that can be
encountered when merging code from a large number of other packages into
ObsPy.  This situation shows how hard it is to package and release
software.  As a result, practices in seismology require careful thought.
If such thought is not done, the problems will get much worse,
especially for future seismological work and for succeeding generations.

A relevant illustrative example is ObsPy, a framework for processing
seismology data that has become popular with students.  However, its
philosophy of rapid development is today progressing without forethought
and good practice, as evidenced by the @emph{LibmSeed} license problem.
In fact, Till 2016, obspy was not legally suitable for source release as
it was, unless libmseed was stripped from it.

@c @section ObsPy Framework for Processing Seismological Data.

@inlineifset{mrg, @opar{@point{} ObsPy [LibmSeed];, Problems Merging
Codes;, Hard to package and release software;, Practices in Seismology
require careful thought,}}

@inlineifset{mrg, @opar{+ ObsPy LibmSeed Routines;, libmseed-2.6.2:
obspy-readbuffer.c packdata.c unpackdata.c;, Pack Routines taken from
qlib2;, Incompatible Licenses.,}}

Developers of the Python Framework for Processing Seismological Data
(ObsPy) have taken a step in the right direction by promoting
principled, community-minded seismological computations.  Particularly
important was the replacement of the pack routines in the ObsPy
Mini-Seed Library called LibmSeed.  The library is a framework for
manipulating the @emph{Standard for the Exchange of Earthquake Data}
[Seed] Data Records.  There were two source files involved, namely,
@file{packdata.c} and @file{unpackdata.c}; both taken from the
@code{qlib2} library developed by Berkeley Seismological Laboratory
Information Systems Manager Douglas Neuhauser
@uref{http://www.ncedc.org/qug/software/ucb/}.  The two routines were
called from @code{obspy/io/mseed/src/libmseed/obspy-readbuffer.c}, The
modifications were done and released by Chad Trabant @minus @ Deputy
Director for Projects at Iris @minus @ in Version 2.6.2 of LibmSeed
tagged on GitHub as @code{libmseed-2.6.2} on Sep 23, 2016.  The problem
originated from the incompatible terms of the GNU Lesser General Public
License (LGPL) and the University of California Berkeley License.  The
explicit restriction from commercial use made the software source code
proprietary, contradicting the usage terms of the LGPL.  Till then,
ObsPy was not legally suitable for source release as it was, unless
LibmSeed was stripped from it.

Try - remember you wanted a space! -

$ awk '/inlineifset/ {sub (/@inlineifset{mrg, @opar{@bullet{}/, " "); print}' RS= ORS="\n\n" file
  @subsubsection ObsPy LibmSeed License Problem,,,,}}

@inlineifset{mrg, @opar{@point{} ObsPy [LibmSeed];, Problems Merging
Codes;, Hard to package and release software;, Practices in Seismology
require careful thought,}}

@inlineifset{mrg, @opar{@point{} ObsPy [LibmSeed];, Problems Merging
Codes;, Hard to package and release software;, Practices in Seismology
require careful thought,}}

@inlineifset{mrg, @opar{+ ObsPy LibmSeed Routines;, libmseed-2.6.2:
obspy-readbuffer.c packdata.c unpackdata.c;, Pack Routines taken from
qlib2;, Incompatible Licenses.,}}
1 Like

It would be good to also remove the ,,,,}} of the sections commands.

A command that has also worked is

sed -n '/inlineifset/,/^ *$/p' $flnm |\
  sed 's/@inlineifset{mrg, @opar{@bullet{} @//g' >> $ofln

Hi
no pipe needed

sed '/inlineifset/,/^ *$/!d; s/@inlineifset{mrg, @opar{@bullet{} @//' $flnm
1 Like

Ok, I found I can also write the commands on multiple lines

sed '/inlineifset/,/^ *$/!d; s/@inlineifset{mrg, @opar{@bullet{} @//' $flnm
 

is then rewritten as

 sed '/inlineifset/,/^ *$/!d;
  s/@inlineifset{mrg, @opar{@bullet{} @//' $flnm
 

When I find

@inlineifset{mrg, @opar{@bullet{} @@subsection Complications of External
Dependencies,,,,}}

I want to put things in one line and also remove the ,,,,}} at the end

@subsection Complications of External Dependencies

How about

awk '/inlineifset/ {gsub (/@inlineifset{mrg, @opar{@bullet{} |,,,,}}/, ""); print}' RS= ORS="\n\n" file

or, if you insist on sed ,

sed '/inlineifset/,/^ *$/!d; s/@inlineifset{mrg, @opar{@bullet{} \(.*\),,,,}}/\1/' file

I am going to stop this here as it actually answers the original task.

Hey @RudiC