Possible Duplicate:
Different ways to execute a shell script

What are the specific differences between the commands listed below?

. <scriptname>
bash <scriptname>

Can anyone explain the differences in simple words, please?

marked as duplicate by jasonwryan, manatwork, Shawn J. Goff, Caleb, Renan Dec 6 '12 at 11:29

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.

  • the commands are 1 ./ scriptname 2 . scriptname 3 bash scriptname – chayanupadhyay Dec 6 '12 at 6:17

./<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.

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