/bin/sh^M:bad interpreter:No such file or directory異常
1376 ワード
Windowsで編集したファイル、例えばshスクリプト、linuxに転送して実行できないという問題によく遭遇します.エラーは以下の通りです.
分析:これは異なるシステムの符号化フォーマットによるものです:windowsシステムで編集しました.shファイルに非表示文字がある場合がありますので、Linuxシステムで実行すると上記の異常情報が表示されます.
ソリューション:
私たちのファイルがcommandだと仮定します.sh
再実行./command.shでいいです.
/bin/sh^M: bad interpreter: No such file or directory
分析:これは異なるシステムの符号化フォーマットによるものです:windowsシステムで編集しました.shファイルに非表示文字がある場合がありますので、Linuxシステムで実行すると上記の異常情報が表示されます.
ソリューション:
私たちのファイルがcommandだと仮定します.sh
1. chmod 777 command.sh
2. vim command.sh
3. :set ff :set fileformat //
4. // , = dos
fileformat=dos fileformat=unix
5. :set ff=unix :set fileformat=unix //
6. wq //
再実行./command.shでいいです.