4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【自分用メモ】シェルスクリプト実行時に/bin/bash^M: bad interpreter: No such file or directoryが出力される

Posted at

Qiita初投稿です。

自分用のメモだけでなく、ググってもなかなかヒットせずなんとか自己解決に導いたものなどをどんどんアウトプットできれば嬉しいな、と考えています。

事象

Visual Studio Codeで作成したシェルスクリプトをubuntuで実行しようとしたところ、以下のエラーが出力された。

-bash: ./hoge.sh: /bin/bash^M: bad interpreter: No such file or directory

原因と対策

Visual Studio Codeで作成したシェルスクリプトの改行コードがCRLFになっていたため。
改行コードをLFに修正することで問題なく実行できた。

4
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?