title: Select lines between two patterns using variables inside SED command
body: <p>I'm new to shell scripting. My requirement is to retrieve lines between two pattern, its working fine if I run it from the terminal without using variables inside sed cmd. But the problem arises when I put all those below cmd in a file and tried to execute it. </p>
  
  <pre><code>#!/bin/sh
  word="ajp-qdcls2228.us.qdx.com%2F156.30.35.204-8009-34"
  upto="2017-01-03 23:00"
  fileC=`cat test.log`
  output=`echo $fileC | sed -e "n/\$word/$upto/p"`
  printf '%s\n' "$output"
  </code></pre>
  
  <p>If I use the below cmd in the terminal it works fine</p>
  
  <pre><code>sed -n '/ajp-qdcls2228.us.qdx.com%2F156.30.35.204-8009-34/,/2017-01-03 23:00/ p' test.log
  </code></pre>
  
  <p>Please suggest a workaround.</p>