您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

Shell-如何查找某些命令的目录?

Shell-如何查找某些命令的目录?

如果您使用的是Bash或zsh,请使用以下命令:

type -a lshw

这将显示目标是内置,函数,别名还是外部可执行文件。如果是后者,它将显示在中显示的每个位置PATH

bash$ type -a lshw
lshw is /usr/bin/lshw
bash$ type -a ls
ls is aliased to `ls --color=auto'
ls is /bin/ls
bash$ zsh
zsh% type -a which
which is a shell builtin
which is /usr/bin/which

在Bash中,对于函数type -a还将显示函数定义。您可以declare -f functionname用来做同样的事情(您必须对zsh使用它,因为type -a没有这样做)。

其他 2022/1/1 18:14:41 有443人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶