title: sed command failure in hashicorp packer shell provisioner
body: <p>Using sed command's in-place update, I'm trying to search a string in a file, and replace it with multiple lines. This is how I would like to update the file.</p>
  
  <p>Before sed: foo.sh</p>
  
  <pre><code>#!/bin/sh
  </code></pre>
  
  <p>sed command:</p>
  
  <pre><code>sed -i 's|#!\/bin\/sh|#!\\/bin\\/sh\n\n. \\/etc\\/company\\/aws_functions\n\nif [ -f \\/etc\\/company\\/user_data ];then\n\t. \\/etc\\/company\\/user_data\nfi\n|g' /tmp/foo.sh
  </code></pre>
  
  <p>After sed: foo.sh</p>
  
  <pre><code>#!/bin/sh
  
  . /etc/company/aws_functions
  
  if [ -f /etc/company/user_data ];then
      . /etc/company/user_data
  fi
  </code></pre>
  
  <p>This works perfectly, however when trying to execute the same command using packer shell provisioner, I keep getting following error.</p>
  
  <pre><code>sed: -e expression #1, char 23: unterminated `s' command[0m
  </code></pre>
  
  <p>I followed <a href="https://github.com/hashicorp/packer/issues/9091" rel="nofollow noreferrer">https://github.com/hashicorp/packer/issues/9091</a> as well, but no luck. Any pointers to fix this would be appreciated. Thanks.</p>