bin/sh^M: bad interpreter: No such file or directory解決

轉自:https://www.cnblogs.com/felixzh/p/6108345.html

問題:bin/sh^M: bad interpreter: No such file or directory

原因:.sh腳本在windows系統下用記事本文件編寫的。不同系統的編碼格式引起的。

解決方法:修改.sh文件格式

   (1)使用vi工具

      vi test.sh

    (2)利用如下命令查看文件格式 

     :set ff 或 :set fileformat 

     可以看到如下信息 

     fileformat=dos 或 fileformat=unix 

     (3) 利用如下命令修改文件格式 

     :set ff=unix 或 :set fileformat=unix 

     :wq (存盤退出)

注:其實,在windows下通過git bash可以直接編寫unix格式.sh!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章