Possible Duplicate:
Different ways to execute a shell script
What are the specific differences between the commands listed below?
./<scriptname>
. <scriptname>
bash <scriptname>
Can anyone explain the differences in simple words, please?
Possible Duplicate:
Different ways to execute a shell script
What are the specific differences between the commands listed below?
./<scriptname>
. <scriptname>
bash <scriptname>
Can anyone explain the differences in simple words, please?
./<scriptname>
executes <scriptname>
in a child process and waits for it to exit.
. <scriptname>
executes <scriptname>
in the same process; the reasons this is used are usually to allow <scriptname>
to modify the environment, and to perform additional actions without the resource cost of spawning a new process.
bash <scriptname>
tells bash to run <scriptname>
. If <scriptname>
has a shebang with the path to bash (#!/bin/bash
) at the top, it will have the same effect as just executing <scriptname>
. If <scriptname>
points to another interpreter (#!/bin/sh
), then <scriptname>
would normally be interpreted by that program, but you are overriding that by asking bash to interpret it.