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 have several utility programs that I need to run. What I am doing write now is going to the bin directory of thee apps and running .\ to run them. Obviously not practical to run it everywhere this way. Putting the bin directory on my path would still not allow these scripts to be executed anywhere would it? So how should a .sh file be run from another directory?

share|improve this question
You need to adjust the PATH environment variable‌​. – Oliver Salzburg May 10 '12 at 23:50
up vote 1 down vote accepted

Open the Terminal and edit the .bash_profile

You can add:

export PATH=<path to script folder(s)>:$PATH

Now run

. ~/.bash_profile

to update your terminal, then try:

which <scriptname>

If you see your script, all should be good!

share|improve this answer
but how would I then run the scripts? ./ – Code Droid May 11 '12 at 1:17
How would I execute the script? – Code Droid May 11 '12 at 1:18
<scriptname> from the Terminal. Just use the name, and if you're not sure, it should have tab completion. – MaddHacker May 11 '12 at 1:20
Oh I see. Just should now run it. – Code Droid May 11 '12 at 1:21
Yup, hope that helped! Keep in mind that the PATH is order dependent to, so when you run a command, it will look for the command in the folder in the order specified by the PATH environment variable (to view just run echo $PATH), meaning if you have 2 commands with the same name, the PATH order will determine which is run. – MaddHacker May 11 '12 at 1:31

You must log in to answer this question.

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