目錄
- 問題
- 解決
- 參考
問題
執行一個shell腳本傳回錯誤:
Not able to execute a .sh file: /bin/bash^M: bad interpreter
,發現是從Windows系統拷貝去Linux系統,回車換行符導緻。需要将行結尾修改成Line feeder.
解決
sed -i -e 's/\r$//'
或者用vi編輯器打開:
:set ff=unix
:wq
:%s/^M//gc