title: How to select multiple lines from a file or from pipe in a script?
body: <p>I'd like to have a script, called <code>lines.sh</code> that I can pipe data to to select a series of lines.</p>
  
  <p>For example, if I had the following file:</p>
  
  <p><strong>test.txt</strong></p>
  
  <pre><code>a 
  b
  c
  d
  </code></pre>
  
  <p>Then I could run:</p>
  
  <pre><code>cat test.txt | lines 2,4
  </code></pre>
  
  <p>and it would output</p>
  
  <pre><code>b
  d
  </code></pre>
  
  <p>I'm using zsh, but would prefer a bash solution if possible.</p>