title: Using variable with sed in Shell Script
body: <p>I'm writing a shell script to edit
   Change-Set attributes of aegis. The
   command I'm using is:</p>
  
  <blockquote>
  <pre><code>aegis -Change_Attributes -Edit
  </code></pre>
  </blockquote>
  
  <p>which opens up a vi editor to carry
   out the changes. I want to do a search
   and replace:</p>
  
  <blockquote>
  <pre><code>s/brief_description \= \"none\"\;/brief_description \=
  </code></pre>
    
    <p>\"test\"/g</p>
  </blockquote>
  
  <p>Can I pass these directly to the open
   vi instance via the script without
   typing in any of it? I want to save
   the document (:wq) after editing it.</p>
  
  <p>P.S. The file is a temporary file
   created when executing the command so
   I don't know the original path</p>
  
  <p><strong>Edit:</strong> I could used sed in this case:</p>
  
  <blockquote>
  <pre><code>sed -e 's/brief_description\ \=\ \"none\"\;/brief_description\ \=\
  </code></pre>
    
    <p>\"test\"\;/g' </p>
  </blockquote>
  
  <p>The solution (inelegant hack??) would
   be to "cat" the output from aegis
   (setenv VISUAL cat), modify the out
   put stream with the above command and
   save it to a temp file, and use :</p>
  
  <blockquote>
  <pre><code>aegis -change_attributes -file &lt;temp file&gt;
  </code></pre>
  </blockquote>
  
  <p><strong>EDIT2:</strong> I've almost got it to work. But there's a problem with the way I use <code>sed</code></p>
  
  <p>I have the following line in my script:</p>
  
  <pre><code>sed -i 's/brief_description\ \=\ \"none\"\;/brief_description\ \=\ \"${DESC}\"\;/g' temp_next.txt
  </code></pre>
  
  <p>But the $DESC variable does not evaluate to its value and the out put is given as:</p>
  
  <blockquote>
    <p>brief_description = "${DESC}";</p>
  </blockquote>
  
  <p>How can I pass DESC to sed that it would evaluate to it's actual value?</p>
  
  <p><strong>EDIT3:</strong></p>
  
  <p>Using </p>
  
  <pre><code>sed -i 's%brief_description\ \=\ \"none\"\;%brief_description\ \=\ \"'"$DESC"'\"\;%g' temp_next.txt
  </code></pre>
  
  <p>worked. I replace the normal delimiter (/) with % and put the environment variable in double quotes. </p>