^M: bad interpreter:解決方法

在Linux中執行.sh腳本,異常提示/bin/sh^M: bad interpreter: No such file or directory。windows

分析:
這是不一樣系統編碼格式引發的:在windows系統中編輯的.sh文件可能有不可見字符,因此在Linux系統下執行會報以上異常信息。ide




首先要確保文件有可執行權限 
#sh>chmod a+x filename編碼

而後修改文件格式 
#sh>vi filenameunix

利用以下命令查看文件格式 
:set ff 或 :set fileformatorm

能夠看到以下信息 
fileformat=dos 或 fileformat=unixit

利用以下命令修改文件格式 
:set ff=unix 或 :set fileformat=unixform

:wq (存盤退出)class



便可解決;file

相關文章
相關標籤/搜索