title: Linux: Append variable to end of line using line number as variable
body: <p>I am new to shell scripting. I am using ksh.</p>
  
  <p>I have this particular line in my script which I use to append text in a variable <code>q</code> to the end of a particular line given by the variable <code>a</code>
   containing the line number .</p>
  
  <pre><code>sed -i ''$a's@$@'"$q"'@' test.txt
  </code></pre>
  
  <p>Now the variable <code>q</code> can contain a large amount of text, with all sorts of special characters, such as !@#$%^&amp;*()_+:"&lt;>.,/;'[]= etc etc, no exceptions. <br/> For now, I use a couple of sed commands in my script to remove any ' and " in this text (<code>sed "s/'/ /g" | sed 's/"/ /g'</code>), but still when I execute the above command I get the following error <br/></p>
  
  <pre><code>sed: -e expression #1, char 168: unterminated `s' command
  </code></pre>
  
  <p>Any sed, awk, perl, suggestions are very much appreciated</p>