Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

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

1 Answer 1

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