title: sed to grep strings between two patterns
body: <p>I have a list of expressions in a file script.sh like </p>
  
  <pre><code>    1  name1  Pending    flag0
      2  name2  Completed  flag1
      3  name3  Completed  flag-
  </code></pre>
  
  <p>etc.,</p>
  
  <p>I would like to grep specific status between "1" and "pending" (i.e name1). </p>
  
  <p>I tried with this command</p>
  
  <pre><code>    var="1"
  
      cat script.sh |sed -n "s/^${var}\(.*\)Pending.*$/\1/gp"
  </code></pre>
  
  <p>this doesn't return anything.</p>