title: Error using sed with -i flag inside a bash for loop
body: <p>I have this code:</p>
  
  <pre><code>for f in $(find -E . -type f ! -regex ".*(zip|png|jpeg|jar|ear|ttf|jpg|git)") ! -path .git; do echo $'\nFile: '$f; sed "$(( $(wc -l &lt;$f) / 2 ))"',$d' $f; done
  </code></pre>
  
  <p>And it seems to be working well. The problem is that if I change it to:</p>
  
  <pre><code>for f in $(find -E . -type f ! -regex ".*(zip|png|jpeg|jar|ear|ttf|jpg|git)") ! -path .git; do echo $'\nFile: '$f; sed -i "$(( $(wc -l &lt;$f) / 2 ))"',$d' $f; done
  </code></pre>
  
  <p><strong>Note the -i option in the sed command. I get this error:</strong></p>
  
  <blockquote>
    <p>sed: 1: "./some/path/ ...": invalid command code .</p>
  </blockquote>