什么相当于 Windows 10 PowerShell 中的 bash/shell/UNIX-terminal 命令“which”?

Posted

技术标签:

【中文标题】什么相当于 Windows 10 PowerShell 中的 bash/shell/UNIX-terminal 命令“which”?【英文标题】:What is the equivalent to the bash/shell/UNIX-terminal command 'which' in Windows 10 PowerShell? 【发布时间】:2021-08-20 08:33:16 【问题描述】:

如何使用PowerShell检查程序可执行文件的位置?

bash shell 中(例如对于 Python):

$ which python
/c/Users/user/.pyenv/pyenv-win/shims/python

【问题讨论】:

***.com/questions/63805/… 感谢@Daniel 提供额外资源。 这能回答你的问题吗? Equivalent of *Nix 'which' command in PowerShell? 这与@Daniel 已经发布的链接相同。提供了几个答案和基本原理,但我喜欢下面马丁回答的简洁。我的范围不需要其他任何东西,它就可以工作。 是的,但他们实际上并没有投票赞成重复关闭。 gcm 的答案也是骗人的:***.com/a/63891/3001761。您可能不需要其他选项,但此过程的重点是为下一个人找到可能的。 【参考方案1】:

我为此使用Get-Command cmdlet(简称gcm):

gcm python

【讨论】:

以上是关于什么相当于 Windows 10 PowerShell 中的 bash/shell/UNIX-terminal 命令“which”?的主要内容,如果未能解决你的问题,请参考以下文章

PowerShe 命令行调试指引(转)

什么相当于 Windows 10 PowerShell 中的 bash/shell/UNIX-terminal 命令“which”?

什么相当于 Windows 中的 Linux mkdir -p?

powershell 来自https://stackoverflow.com/questions/31051103/how-to-export-a-class-in-powershell-v5-mod

如何获取以常用词开头的所有 Windows 服务名称?

哪些方法可以绕过PowerShell Execution Policy?