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

When I created a shell script for the first time and executed it, an error occurred, so make a note.

Created shell script

Create a script file.

$ touch script.sh

The script I was creating is below. A simple script that just displays Hello.

#!/usr/bin/bash
echo Hello

Run

When executed,

$ ./script.sh

I get an error

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

approach

Check which bash you are using because the specified bash is different. What was used here was / bin / bash.

$ which bash
/bin/bash

I was able to execute it by modifying the contents of the script as follows.

#!/bin/bash
echo Hello

I'm a beginner and I don't understand it in the first article, but for the time being. Please let me know if you make a mistake.

Recommended Posts

-bash: ./ {file name} .sh: /usr/bin/bash: bad interpreter: No such file or directory
NO MORE “cd: foo: No such file or directory”
No such file or directory:'chromedriver': Resolve'chromedriver'
pip install --upgrade pip will result in No such file or directory
Import Error: libffi.so.6: cannot open shared object file: No such file or directory
Cannot import cv2 (libgtk-x11-2.0.so.0: cannot open shared object file: No such file or directory)
Addressed "Python .h: No such file or directory" when installing uWSGI with Python 3.8
What to do when [Errno 2] No such file or directory appears in Python
What to do if ENOENT: no such file or directory appears during npm install
When I try to run the pip command after updating pip, I get "No such file or directory"
A story about what to do when a bad interpreter: Not such file or directory appears in Anaconda3 and how to investigate the cause.
[Note] How to deal with unicode error and No such file or directory (output table to excel file with pandas)
When bus = smbus.SMBus (1) gets IOError: [Errno 2] No such file or directory when trying to start the GrovePi starter kit