title: Unable to alter file with sed when file is created in bash script
body: <p>Running Windows (Git Bash).</p>
  <p>Said script is supposed to make a copy off httpd.conf to httpd.conf.ORIG and then run sed on the .ORIG file and redirect output back to .conf.</p>
  <p>HOWEVER.</p>
  <p>Sed will not make changes and save to the httpd.conf file if I make a copy of the .conf file to a .ORIG version inside of the script (as shown below). I have to remove the if statement and make the copy on the command line manually and then run the script. In doing so, it works...</p>
  <p>Why in the world is this? (I only am using redirection here instead -i with sed on the original .conf file because that also will not work).</p>
  <p>It has me totally puzzled.</p>
  <p>Script in question is below:</p>
  <pre><code>if [[ ! -f &quot;/c/xampp/apache/conf/httpd.conf.ORIG&quot; ]]
  then
      cp /c/xampp/apache/conf/httpd.conf /c/xampp/apache/conf/httpd.conf.ORIG
  fi
  
  WORKINGDIR=$(echo &quot;$PWD&quot; | sed -e 's/^\/c/C:/g;s/\//\\\\/g')
  ROOTLOC=$(grep &quot;DocumentRoot \&quot;&quot; /c/xampp/apache/conf/httpd.conf.ORIG)
  DIRLOC=$(grep -m 1 &quot;&lt;Directory \&quot;&quot; /c/xampp/apache/conf/httpd.conf.ORIG)
  
  sed &quot;s~${DIRLOC}~&lt;Directory \&quot;${WORKINGDIR}\&quot;&gt;~g;s~$ROOTLOC~DocumentRoot \&quot;${WORKINGDIR}\&quot;~g&quot; /c/xampp/apache/conf/httpd.conf.ORIG &gt; /c/xampp/apache/conf/httpd.conf
  </code></pre>