mysql bash profile,在.bash_profile中设置路径

Why does setting a PATH require the :${PATH} at the end?

PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"

When I append a path to this I would do

PATH=$PATH:...

How do I append a PATH without going to a new line. That is, how would I append a PATH to the original PATH statement.

If I wanted to put the following all in the first line, for instance. How does this interact with the :${PATH} part?

PATH=$PATH:/usr/local/mysql/bin

解决方案

There's a difference between appending an existing path to the front or the end of the $PATH environment variable. The way bash resolves execution paths is by starting from the front of the list. That means if you have these two directories in your path:

PATH="/dir1/bin:/dir2/bin"

And they both have the executable test.sh in it, then when you run test.sh, it'll execute the one in /dir1/bin/test.sh since that directory appears first in the path.

Additionally, ${PATH} is the same as $PATH.

PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"

is simply adding /Library/Frameworks/Python.framework/Versions/2.7/bin to the front of the path and

PATH=$PATH:/usr/local/mysql/bin

is simply adding /usr/local/mysql/bin to the end of the path.

So how do you do both in one line? Something like this:

PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}:/usr/local/mysql/bin"

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值