# Selecting section and removing match

**URL:** <https://community.unix.com/t/selecting-section-and-removing-match/377194>\
**Category:** Shell Programming and Scripting\
**Created:** [February 7, 2020, 4:33pm UTC](https://community.unix.com/t/selecting-section-and-removing-match/377194 "2020-02-07T16:33:57Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Danette](https://community.unix.com/letter_avatar/danette/32/6_22734026db12803ebb3e059622ac3534.png) [@Danette](https://community.unix.com/u/Danette)\
**Post date:** [February 7, 2020, 4:33pm UTC](https://community.unix.com/t/selecting-section-and-removing-match/377194/1 "2020-02-07T16:33:57Z")

</div>

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

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

```

I had written the following command but it messed my file

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

```

The result should be

```nohighlight
@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.,}}

```

```nohighlight
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.

```

---

<div class="post-metadata">

**Author:** ![RudiC](https://community.unix.com/letter_avatar/rudic/32/6_22734026db12803ebb3e059622ac3534.png) [@RudiC](https://community.unix.com/u/RudiC)\
**Post date:** [February 7, 2020, 7:30pm UTC](https://community.unix.com/t/selecting-section-and-removing-match/377194/2 "2020-02-07T19:30:03Z")

</div>

Try - remember you wanted a space! -

```nohighlight
$ 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.,}}

```

---

<div class="post-metadata">

**Author:** ![Danette](https://community.unix.com/letter_avatar/danette/32/6_22734026db12803ebb3e059622ac3534.png) [@Danette](https://community.unix.com/u/Danette)\
**Post date:** [February 8, 2020, 5:09am UTC](https://community.unix.com/t/selecting-section-and-removing-match/377194/3 "2020-02-08T05:09:26Z")

</div>

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

A command that has also worked is

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

```

---

<div class="post-metadata">

**Author:** ![nezabudka](https://community.unix.com/letter_avatar/nezabudka/32/6_22734026db12803ebb3e059622ac3534.png) [@nezabudka](https://community.unix.com/u/nezabudka)\
**Post date:** [February 8, 2020, 5:42am UTC](https://community.unix.com/t/selecting-section-and-removing-match/377194/4 "2020-02-08T05:42:54Z")

</div>

Hi  
no pipe needed

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

```

---

<div class="post-metadata">

**Author:** ![Danette](https://community.unix.com/letter_avatar/danette/32/6_22734026db12803ebb3e059622ac3534.png) [@Danette](https://community.unix.com/u/Danette)\
**Post date:** [February 8, 2020, 12:08pm UTC](https://community.unix.com/t/selecting-section-and-removing-match/377194/5 "2020-02-08T12:08:08Z")

</div>

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

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

```

is then rewritten as

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

```

When I find

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

```

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

```nohighlight
@subsection Complications of External Dependencies

```

---

<div class="post-metadata">

**Author:** ![RudiC](https://community.unix.com/letter_avatar/rudic/32/6_22734026db12803ebb3e059622ac3534.png) [@RudiC](https://community.unix.com/u/RudiC)\
**Post date:** [February 8, 2020, 12:58pm UTC](https://community.unix.com/t/selecting-section-and-removing-match/377194/6 "2020-02-08T12:58:50Z")

</div>

How about

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

```

or, if you insist on `sed` ,

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

```

---

<div class="post-metadata">

**Author:** ![Danette](https://community.unix.com/letter_avatar/danette/32/6_22734026db12803ebb3e059622ac3534.png) [@Danette](https://community.unix.com/u/Danette)\
**Post date:** [February 8, 2020, 3:07pm UTC](https://community.unix.com/t/selecting-section-and-removing-match/377194/7 "2020-02-08T15:07:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://community.unix.com/uploads/default/original/2X/c/c7e9e16a595259edafe88615719d5c5dcda035c2.png) [@system](https://community.unix.com/u/system)\
**Post date:** [August 9, 2020, 7:22pm UTC](https://community.unix.com/t/selecting-section-and-removing-match/377194/8 "2020-08-09T19:22:56Z")

</div>

Automatically bumped on August 9, 2020, 7:22pm UTC



---

<div class="post-metadata">

**Author:** ![Neo](https://community.unix.com/user_avatar/community.unix.com/neo/32/22838_2.png) [@Neo](https://community.unix.com/u/Neo)\
**Post date:** [August 10, 2020, 5:42am UTC](https://community.unix.com/t/selecting-section-and-removing-match/377194/9 "2020-08-10T05:42:22Z")

</div>

Hey @RudiC

 ![](https://media.tenor.com/videos/2110865ec367ca7a2329ca5830626ec7/mp4)
