如何将搜索路径添加到“哪个”?(How to add search path into “which”?)

编程入门 行业动态 更新时间:2024-10-08 10:37:35
如何将搜索路径添加到“哪个”?(How to add search path into “which”?)

当我输入which testWhich ,其中testWhich是~/test文件夹下的可执行文件时,我看到了

/usr/bin/which: no testWhich in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin) 。

我想知道如何将~/test文件夹添加到搜索路径中which这样我就可以在终端的任何地方执行testWhich 。

When I type which testWhich, where testWhich is an executable file under ~/test folder, I see

/usr/bin/which: no testWhich in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin).

I'd like know how to add ~/test folder into the search path of which so that I can execute testWhich anywhere in the terminal.

最满意答案

如在其中的联机帮助页:

它通过在PATH中搜索与参数名称匹配的可执行文件来完成此操作。

你应该在你的PATH环境变量中添加〜/ test。 使用以下命令在bash shell上执行此操作:

export PATH =〜/ test:$ PATH

As in the manpage of which:

it does this by searching the PATH for executable files matching the names of the arguments.

you should added ~/test to your PATH environment variables. for doing it on bash shell, using the following command:

export PATH=~/test:$PATH

更多推荐

本文发布于:2023-08-03 20:19:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1400878.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何将   路径   add   search   path

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!