Translate

August 22, 2013

DOS format file and how to fix this in Vim

Background

You may have experienced that a script will not run on a linux machine after being edited on Windows. You get an EOF error or " bad interpreter /bin/sh^M"

The problem

This is due to how Windows file adds the line break at the end of each line. To check if this is your problem, open the file in vim. You will see ^M at the end of each line. You may also get a message related to DOS at the bottom of the window.

Solution

To fix this, there is a simple command in Vim. Type:
 :setlocal ff=unix  
And you will get the file with the correct. Save the file and, now, you will be able to run it.

No comments:

Post a Comment