title: Delete all lines in a text file that do not contain a string
body: <p>So I've got a txt file where each line is a file path, I would like to:</p>
  
  <ol>
  <li>Read this txt file (line-by-line).</li>
  <li>Delete all lines that do not end with <code>,-,.txt</code></li>
  <li>In the remaining lines, delete everything from after the last <code>/</code> to the <code>,-,.txt</code>.</li>
  <li>Write the output to a new txt. </li>
  </ol>
  
  <p>How could this be done with sed?</p>
  
  <p>Input:</p>
  
  <pre><code>/a/b1/
  /a/b1/car
  /a/b1/car/bil/
  /a/b1/car/bil/,-,.txt
  /a/b2/
  /a/b2/flower
  /a/b2/flower/bil/
  /a/b2/flower/bil/,-,.txt
  /a/b2/
  /a/b2/boat
  /a/b2/boat/baat/
  /a/b2/boat/baat/abc,-,.txt
  </code></pre>
  
  <p>Second step:</p>
  
  <pre><code>/a/b1/car/bil/,-,.txt
  /a/b2/flower/bil/,-,.txt
  /a/b2/boat/baat/abc,-,.txt
  </code></pre>
  
  <p>Third step/desired output:</p>
  
  <pre><code>/a/b1/car/bil/
  /a/b2/flower/bil/
  /a/b2/boat/baat/
  </code></pre>