title: escaping the dollar sign
body: <p>I have a line in my.cnf file </p>
  
  <pre><code>datadir = /var/lib/mysql
  </code></pre>
  
  <p>The following changes it to mysql3307 as expected.</p>
  
  <pre><code>sed -i 's/\/var\/lib\/mysql$/\/var\/lib\/mysql3307/' /etc/my.cnf
  </code></pre>
  
  <p>But if I have the following:</p>
  
  <pre><code>datadir = /var/lib/mysql/
  </code></pre>
  
  <p>Then the following does not change the path as expected:</p>
  
  <pre><code>sed -i 's/\/var\/lib\/mysql\/$/\/var\/lib\/mysql3307/' /etc/my.cnf
  </code></pre>
  
  <p>I want to change the path to mysql3307 where datadir is /var/lib/mysql (with or without /)</p>
  
  <p>Update:</p>
  
  <p>Here is the issue: 
  Both the above commands works on one server and none of them works on another.</p>
  
  <p>The following works as expected, but I need to add that $ to indicate the lines ending with mysql/</p>
  
  <pre><code>sed -i 's/\/var\/lib\/mysql\//\/var\/lib\/mysql3307/' /etc/my.cnf
  </code></pre>
  
  <p>Observed:</p>
  
  <p>The carot sign ^ works as expected, but end of line sign $ does not. Any clue?</p>
  
  <p>Update:</p>
  
  <p>It seems to be working after using "dos2unix" command.</p>