Skip to main content
Expanded explanation.
Source Link
dhag
  • 16.3k
  • 4
  • 57
  • 66

The first version, with an explicit call to sh will run your script with sh (displaying trace statements, as requested by sh-x). The second one, which does not specify an explicit interpreter, will respect the shebang line, if any, or default to the shell you are currently running.

For example, if your script has a shebang line of #! /bin/bash, or your shell is bash, then, the second form ./script will cause execution to run bash rather than sh. Since bash is a more full-featured shell than sh, it may have different performance characteristics.

The first version, with an explicit call to sh will run your script with sh. The second one, which does not specify an explicit interpreter, will respect the shebang line, if any, or default to the shell you are currently running.

The first version, with an explicit call to sh will run your script with sh (displaying trace statements, as requested by -x). The second one, which does not specify an explicit interpreter, will respect the shebang line, if any, or default to the shell you are currently running.

For example, if your script has a shebang line of #! /bin/bash, or your shell is bash, then, the second form ./script will cause execution to run bash rather than sh. Since bash is a more full-featured shell than sh, it may have different performance characteristics.

Source Link
dhag
  • 16.3k
  • 4
  • 57
  • 66

The first version, with an explicit call to sh will run your script with sh. The second one, which does not specify an explicit interpreter, will respect the shebang line, if any, or default to the shell you are currently running.