title: sed not parsing variable
body: <p>I'm stuck with a bash script here...</p>
  
  <p>I have variables: </p>
  
  <pre><code>hostname1="sxxx" hostname2="vbbbb" hostname3="sggg" hostname4="aaa" ...
  </code></pre>
  
  <p>I'm trying to change the 12th line of every files in a folder with the host-name variables.</p>
  
  <p>The files are  <code>server1.txt server2.txt server3.txt server4.txt ...</code></p>
  
  <p>I'm trying to do this with a while loop:</p>
  
  <pre><code>i=1
  imax=1
  
  while [[ $i -le 20 ]]
  do
  
      sed -i "12s/.*/$hostname$imax/" server$((imax)).txt
  
      (( i++ ))
      (( imax++ ))
  
          if [[ imax -eq 21 ]]
              then
                  imax=1
          fi
  
  done
  </code></pre>
  
  <p>what I want to do with <code>sed</code> is to concatenate the word host-name with imax and then use it as variable.
  Maybe with this I'm clear enough:</p>
  
  <pre><code>$hostname=hostname$imax; //for exammple 
  sed -i "12s/.*/$hostname/" server$((imax)).txt // i need here the variable $hostname to have the content "sxxx"
  </code></pre>