0

Possible Duplicate:
what is the difference between “./somescript.sh” and “. ./somescript.sh”

Please clarify the difference between the shell commands . script.sh vs ./script.sh where script.sh is a shell script.

Thanks

Community
  • 1
  • 1
Surya
  • 147
  • 1
  • 2
  • 7
  • Also http://stackoverflow.com/questions/1880735/difference-between-launching-a-script-with-script-sh-and-script-sh?rq=1 – NPE Jan 20 '13 at 08:41
  • And http://stackoverflow.com/questions/9017763/difference-between-and?rq=1 – NPE Jan 20 '13 at 08:41

1 Answers1

5

The difference is simple

. script.sh

executes the shell script using your current shell, so all changes you do in the script (like change directory or variables) will affect your running shell

./script.sh

on the other hand will start a new shell to execute the script. It is usually the better way to launch scripts

Fabian Henze
  • 980
  • 1
  • 10
  • 27