Saturday, June 12, 2010

Adding path variable in Mac OS

Every day is a learning experience for me. I learn from work. I learn from my activities. So, today I learned how to set a PATH variable in Mac.

I know how to set a PATH variable in windows. That was easy. I'm finding it hard to get a solution that will solve my problem. Because Mac is based on Unix and there're so many different version of Unix out there, the answers that I found are not applicable to me. However, thanks to tech_recipes.com, I was managed to change my path variable.

So, I have to use export command. The format is
export PATH=
and then I can add any path I want at the end of that. So for example, I can do like
export PATH=/user/bin
to set my path variable to /user/bin. This is only for one path. If I want multiple paths, then I have to separate it with a colon. Also, notice that you cannot have any space except between the key words export and PATH.

To see what is your system's current PATH variable, you can type env command. However, if there're existing PATH and if you type in export PATH=/user/bin, the original path will be overwritten. So, you will want to append the path at the end of the existing path. The way to do is that to use $PATH variable. For example, you can do
export PATH=$PATH:/user/bin
. That will add /user/bin to the path variable on top of the original paths.

No comments:

Post a Comment