我在PATH中有一个可执行文件,但在输入命令时找不到它。
$PATH
的结果是:
-bash:/Users/aridyckovsky/.rvm/gems/ruby-2.1.0/bin:/Users/aridyckovsky/.rvm/gems/ruby-2.1.0@global/bin:/Users/aridyckovsky/.rvm/rubies /ruby-2.1.0/bin:/Library/Frameworks/Python.framework/Versions/3.3/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin :/ sbin:/ usr / local / bin:/ opt / X11 / bin:/ usr / local / git / bin:/ usr / local / mysql / bin:/Users/aridyckovsky/.rvm/bin:没有这样的文件或directory`
具体来说,我正在尝试在/ usr / local / bin中执行mongod
,但结果是-bash: mongod: command not found
。但是,我可以在同一位置运行其他可执行文件。有什么想法吗?
答案 0 :(得分:2)
当您尝试将$PATH
作为命令执行时,您将收到该错误。
$ $PATH
bash: /home/glennj/bin:...:/opt/tcl/8.6/bin: No such file or directory
在bash中,使用type
内置来查找内容:
$ type mongod
mongod is /usr/bin/mongod
使用type -a
同时显示别名和功能
$ type -a ls
ls is aliased to `ls -F'
ls is /bin/ls
$ type -a git
git is a function
git ()
{
case "$1" in
push | pull)
if (( $# == 1 )); then
local branch=$(git_current_branch);
if [[ -n $branch ]]; then
set -- $1 origin "$branch";
echo git "$@";
else
echo "You're not in a git-managed directory" 1>&2;
return;
fi;
fi
;;
esac;
command git "$@"
}
git is /usr/bin/git