title: How to pass a variable containing slashes to sed
body: <p>How do you pass a variable containing slashes as a pattern to <code>sed</code>?</p>
  
  <p>For example, if I have the following variable:</p>
  
  <pre><code>var="/Users/Documents/name/file"
  </code></pre>
  
  <p>I want to pass it to <code>sed</code> as so:</p>
  
  <pre><code>sed "s/$var/replace/g" "$file"
  </code></pre>
  
  <p>However I get errors. How can I circumvent the issue?</p>