1

This question already has an answer here:

I have script with #!/bin/ksh in the first line. When I try to execute this script (run ./myscript.sh) the error occurred:

-bash: ./myscript.sh: /bin/ksh: bad interpreter: No such file or directory

But when I execute this script through source myscript.sh or bash myscript.sh command - script runs successfully.

Yes, ksh is not installed and it is correct to install this. But I can't understand different behavior ./ and bash or source

marked as duplicate by ilkkachu bash Sep 12 at 14:21

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

5
  • When a script is executed with ./ the interpreter from the shebang line is invoked.

  • with source the current shell is used (source is a bash extension, so you have to be running bash)

  • with bash script.sh the bash shell in your PATH is invoked with the shellscript.

Not the answer you're looking for? Browse other questions tagged or ask your own question.