Quantcast
Channel: Bashタグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 2811

-bash: ./{file name}.sh: /usr/bin/bash: bad interpreter: No such file or directory

$
0
0

初めてシェルスクリプトを作成して実行したみたところ、エラーが出たのでメモ。

作成したシェルスクリプト

スクリプトファイルを作成。

$ touch script.sh

作成していたスクリプトは以下。
Helloを表示するだけの単純なスクリプト。

#!/usr/bin/bash
echo Hello

実行

実行すると、

$ ./script.sh

エラーが出る

-bash: ./script.sh: /usr/bin/bash: bad interpreter: No such file or directory

対処法

指定しているbashが異なっていることが原因なため、使用しているbashをwhich bashで確認。
ここで使われていたのは/bin/bashだった。

$ which bash
/bin/bash

スクリプトの中身を以下のように修正すると実行できた。

#!/bin/bash
echo Hello

初心者で初記事で理解が及んでいませんがとりあえず。
間違っている等あれば教えてください。


Viewing all articles
Browse latest Browse all 2811

Trending Articles