0

Possible Duplicate:
Why is . not in the path by default?

This question might be trivial but I'm wondering why I have to type the dot and the slash before the name of my script in order to execute it, even though it is located in my current directory.

./my_script.sh

Whenever I type it without the dot & the slash:

my_script.sh

I just get -bash: cloud_sync.sh: command not found

What is the reason behind putting the ./ in front of a script name?

Thanks.

  • I am late to the party, but you can symlink (ln -s /path/to/orig.sh /usr/bin/orig) it to your /usr/bin folder from your scripts directory (/usr/bin is in your $PATH) and then you can just type my_script (it even tab-completes). – nerdwaller Oct 31 '12 at 14:06
1

You need to have your current directory in your PATH, export PATH=${PATH}:.

| improve this answer | |
  • 2
    Note that having your current directory in your path is considered a security risk. There is a good reason this is not the default on multi-user systems. – Hennes Oct 31 '12 at 16:04
  • a better way would we to put user scripts to ~/bin and add this to your PATH variable. – l1zard Nov 1 '12 at 22:41
  • I added current directory as the last path since it's somewhat safer then have it first. The best is of course to be explicit and have them in ~/bin. – Jimmy Hedman Nov 14 '12 at 14:05

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