title: Bash variable in sed command
body: <p>I need to add an header recursively to several file according to the name of the file.</p>
  
  <p>So I have tried:</p>
  
  <pre><code>for i in *file 
  do     
  sed -i '1 i \A;B;C;D;E;F;G;H;${i%??}' a_${i} &gt; header_a_${i}
  done
  </code></pre>
  
  <p>the problem is that the variable reflecting the name of the file does not expand and in the header I have ${i%??} instead of part of the name file (%?? is to remove some ending characters).</p>
  
  <p>Any help would be great. </p>