1

If we have a program start.sh, we can execute it with the sh start.sh. But we could execute it giving permission with chmod and run ./start.sh in the command line. What is the difference between those two ways of executing a bash/sh script.

1 Answers1

1

They both execute shell script but there is some little difference:

sh will use will use the sh interpreter even if a differenter interpreter was indicated in the begining of the file like #!/bin/bash this can be useful if you want your script to be executed using always the same interpreter

for ./start.sh the shell will try to execute as an executable file so the script need a shebang like #!/bin/bash so ./start.sh is more flexible since you can use the interpreter you want

Saxtheowl
  • 2,394
  • 2
  • 12
  • 22