Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

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.

share|improve this answer
thank you Shawn J. Goff... – chayanupadhyay Dec 6 '12 at 6:41

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