title: sed -e 's/^M/d' not working
body: <p>A very common problem, but I am unable to work around it with sed.</p>
  
  <p>I have a script file ( a batch of commands) say <code>myfile.txt</code> to be executed at once to create a list. Now when I am executing a batch operation my command line interface clearly shows its unable to parse the command as a line feed <code>^M</code> is adding up at end of each line.</p>
  
  <p>I thought <code>sed</code> to be the best way to go about it.I tried:</p>
  
  <pre><code>    sed -e 's/^M/d' myfile.txt &gt; myfile1.txt
      mv myfile1.txt myfile.txt
  </code></pre>
  
  <p>It didn't work. I also tried this and it didn't work:</p>
  
  <pre><code>    sed -e 's/^M//g' myfile.txt &gt; myfile1.txt
      mv myfile1.txt myfile.txt
  </code></pre>
  
  <p>Then I thought may be <code>sed</code> is taking it as a M character in the beginning of line, and hence no result. So I tried:</p>
  
  <pre><code>    sed -e 's/\^M//g' myfile.txt &gt; myfile1.txt
      mv myfile1.txt myfile.txt
  </code></pre>
  
  <p>But no change. Is there a basic mistake I am doing ? Kindly advise as I am bad at <code>sed</code>.</p>
  
  <p>I found a resolution though which was to open the file in vi editor and in command mode execute this:</p>
  
  <pre><code>    :set fileformat=unix
      :w
  </code></pre>
  
  <p>But I want it in <code>sed</code> as well.</p>