/bin/bash^M: bad interpreter: No such file or directory

<The problem encountered today, there are many similar articles on the Internet, I personally record it, deepen my memory, and detour if I already understand it.>

 

When executing a script full_build.sh, it keeps prompting me :

-bash: ./full_build.sh: /bin/bash^M: bad interpreter: No such file or directory

 

At first, it said that I didn't have enough permissions to execute it, and then I changed the permissions and kept reporting the above problem.

I remember that a few months ago, I encountered a similar problem. At that time, I was compiling the Android  Framework. Later, I opened the wrong .xml file, and I saw a lot of ^M signs directly. The colleague in   charge of the compilation helped solve it. I didn't ask why, but when I encountered it again today, I searched the Internet and found out the reason.   

 

One of the reasons for the above error is that the script file is in DOS format, that is, the end of each line is marked with \r\n. Use the vim editor to open the script and run:

:set ff?

You can see the words of DOS or UNIX. Use set ff=unix to force it to be in unix format, then save it and exit.

 

There are also many other methods on the Internet, such as: execute the dos2unix command to convert the code, the command is: #dos2unix full_build.sh, but I don't have the dos2unix installation package, so I skip it.  

 

It is also said that the reason for this problem is that I accidentally pressed Ctrl+v when using vim, the script was downloaded from the server by me, and I don’t know how it turned into DOS format.

 

http://blog.csdn.net/esther0401/article/details/7361496

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326300474&siteId=291194637