Super User is a question and answer site for computer enthusiasts and power users. 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

I've correctly added my scripts folder to my $PATH. But I still cannot run the scripts from anywhere by simply calling them. How do I achieve this?

Example. If I have ~/scripts/ in my path and in ~/scripts/ I have I want to be able to be anywhere and type foo and have it execute When I type echo $PATH I see my scripts folder correctly included in my path. I've also made executable because if I cd to the scripts directory and type it runs correctly.

What am I missing?

share|improve this question

migrated from Apr 1 '13 at 18:34

This question came from our site for professional and enthusiast programmers.

up vote 2 down vote accepted

If you type in "", you'll likely start your script up since the path to it is now included in your "$PATH" file.

Right now the shell simply doesn't know how to map "foo" to "".

So maybe you just need to add an alias to your .tcshrc / .bashrc (e.g. "alias foo") or an actual file symlink (e.g. "ln -s foo") to your script and you'll be all set.

share|improve this answer
or just remove the .sh extension its not actually necessary – prodigitalson Apr 1 '13 at 15:19
OK. So if I type from anywhere it works but simply foo doesn't work. Prodigitalson how do you get it so you don't need to specify the file extension? – Jesse Atkinson Apr 1 '13 at 15:22
I offered you two possible solutions, Jesse. Which one seems more straightforward to you? – Michael Dautermann Apr 1 '13 at 15:24
It appears the only way to achieve what I want without declaring the file extension is to also set a symlink or an alias. – Jesse Atkinson Apr 1 '13 at 16:22
@JesseAtkinson I suspect you're coming from a Windows background, where you don't need to type the .exe part to run foo.exe, and Windows "knows" that files with certain extensions are executable. It does this because earlier versions of Windows did not have a file permissions/executable bit like OSX/Unix/Linux. Now that you're using OSX (which is BSD Unix under the hood), you'll just need to get used to the different system. You can name a file whatever you want, and as long as you set the X bit you can run it, but you need to enter its full name. – MattDMo Apr 1 '13 at 19:33

From your description, it should work, except for the part where you seem to want to alias foo to Did you re-source your .profile, .bashrc, or wherever you made the change to PATH afterward? Next you can add an alias from foo

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .