在.bash_profile中设置路径 [英] Setting path in bash_profile

查看:1309
本文介绍了在.bash_profile中设置路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么设置 PATH 要求:$ {PATH}

  PATH =/库/框架/ Python.framework /版本/ 2.7 /斌:$ {PATH}

当我追加到该路径,我会做

  PATH = $ PATH:...

我如何添加一个 PATH 没有去到一个新行。也就是说,我怎么会追加一个 PATH 原来的 PATH 语句。

如果我想要把所有在第一线以下,例如。这怎么与互动:$ {PATH} 部分

  PATH = $ PATH:在/ usr /本地/ MySQL的/ bin中


解决方案

有追加现有路径的前面或 $ PATH 环境变量的末尾之间的差异。该方法的bash解决执行路径是从列表的前面开始。这意味着,如果你在你的路径这两个目录:

  PATH =/ DIR1 /斌:/ DIR2 / BIN

和它们都具有可执行 test.sh 在里面,那么当你运行 test.sh ,它因为该目录首次出现在路径会执行一个在 /dir1/bin/test.sh

此外, $ {PATH} 相同 $ PATH

  PATH =/库/框架/ Python.framework /版本/ 2.7 /斌:$ {PATH}

时,只需添加 /Library/Frameworks/Python.framework/Versions/2.7/bin 的路径前面

  PATH = $ PATH:在/ usr /本地/ MySQL的/ bin中

时,只需添加的/ usr /本地/ MySQL的/斌 应用于路径的末尾

那么,你如何在一行一举两得?事情是这样的:

<$p$p><$c$c>PATH=\"/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}:/usr/local/mysql/bin\"

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"

这篇关于在.bash_profile中设置路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆