2012/02/08

[Linux] Error: bin/bash^M: bad interpreter

Error: bin/bash^M: bad interpreter: no such file or directory
會遇到這個錯誤通常是,執行的 script 檔案是從 windows 上傳到 linux,或是剪下貼上時,換行方式不一樣,導致的。windows 裡換行是 CR+LF,linux 裡只有 LF (CR = \r,LF = \n ….. in ASCII code),所以要把 windows 使用的 \r 換行符號清除掉。

upload 選擇 ASCII text 模式或是手動轉換
方法一:終端機執行
sed -i "s/\r//" FILENAME
方法二:設定 windows 下的軟體的換行模式 (notepad++ 設定很方便,改成 ASCII 模式)

沒有留言:

張貼留言