powershell where

您所在的位置:网站首页 grep只匹配一次 powershell where

powershell where

2023-03-27 22:43| 来源: 网络整理| 查看: 265

powershell where-object_grep查找文件内容 思创斯忠实用户-ss • 2023年3月24日 22:51 • 未分类

powershell where-object_grep查找文件内容CMD中的where命令where命令显示符合搜索模式的文件位置。在默认情况下,搜索是在当前目录和PATH环境变量指定的路径中执行的。where命令对应文件的路径为C:\Windows\System32\where.exe。where命令案例C:\Users\Administrator>wherepythonC:\Users\Administrator\AppData\Local\Programs\Python\Python37\python.exewhere命令帮助C:\Use

大家好,我是你的好朋友思创斯。今天说一说powershell where-object_grep查找文件内容,希望您对编程的造诣更进一步.

CMD中的where命令

where命令显示符合搜索模式的文件位置。在默认情况下,搜索是在当前目录和 PATH 环境变量指定的路径中执行的。 where命令对应文件的路径为C:\Windows\System32\where.exe。

where命令案例 C:\Users\Administrator>where python C:\Users\Administrator\AppData\Local\Programs\Python\Python37\python.exe where命令帮助 C:\Users\Administrator>where /? WHERE [/R dir] [/Q] [/F] [/T] pattern... 描述: 显示符合搜索模式的文件位置。在默认情况下,搜索是在当前目录和 PATH 环境变量指定的路径中执行的。 参数列表: /R 从指定目录开始,递归性搜索并显示符合指定模式的文件。 /Q 只返回退出代码,不显示匹配文件列表。(安静模式) 匹配文件。(安静模式) /F 显示所有相配文件并用双引号括上。 /T 显示所有相配文件的文件的文件。 pattern 指定要匹配的文件的搜索模式。通配符 * 和 ? 可以用在模式中。 也可以指定 "$env:pattern" 和 "path:pattern" 格式; 其中 "env" 是环境变量,搜索是在 "env" 变量的指定的路径中执行的。 这些格式不应该跟 /R 一起使用。此搜索也可以用将 PATHEXT 变 量扩展名附加于此模式的方式完成。 /? 显示此帮助消息。 注意: 如果搜索成功,此工具返回错误级别 0; 如果不成功,返回 1; 如果失 败或发生错误,返回 2。 示例: WHERE /? WHERE myfilename1 myfile????.* WHERE $windir:*.* WHERE /R c:\windows *.exe *.dll *.bat WHERE /Q ??.??? WHERE "c:\windows;c:\windows\system32:*.dll" WHERE /F /T *.dll PowerShell中的where命令

在PowerShell中执行where命令无效。

PS C:\Users\Administrator> where python.exe

根据如下命令可知,在PowerShell中where命令对应的是Where-Object命令,优先级比where.exe高。CMD里的where命令本来全名就是where.exe,只不过可以省略.exe而已。所以实现需要CMD里的where命令功能显式地使用where.exe。

PS C:\Users\Administrator> gcm where -All CommandType Name Version Source ----------- ---- ------- ------ Alias where -> Where-Object Application where.exe 10.0.17... C:\Windows\system32\where.exe

在PowerShell中执行where.exe命令有效。

PS C:\Users\Administrator> where.exe python.exe C:\ProgramData\Anaconda3\python.exe C:\Users\Administrator\AppData\Local\Programs\Python\Python37\python.exe PowerShell中类似where的命令

PowerShell中的gcm和get-command命令与CMD中的where命令相似,注意加上-All才会显示所有满足要求的文件。

PS C:\Users\Administrator> gcm python.exe -All CommandType Name Version Source ----------- ---- ------- ------ Application python.exe 3.8.815... C:\ProgramData\Anaconda3\python.exe Application python.exe 3.7.215... C:\Users\Administrator\AppData\Local\Programs\Python\Python37\python.exe

gcm命令是get-command命令的别名。

PS C:\Users\Administrator> get-command python.exe -All CommandType Name Version Source ----------- ---- ------- ------ Application python.exe 3.8.815... C:\ProgramData\Anaconda3\python.exe Application python.exe 3.7.215... C:\Users\Administrator\AppData\Local\Programs\Python\Python37\python.exe 总结

在PowerShell中使用类似where命令的查找文件功能的方法有三种:

where.exe 文件搜索字符串 gcm 文件搜索字符串 -All get-command 文件搜索字符串 -All 版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

文章由思创斯整理,转载请注明出处:https://ispacesoft.com/111928.html

赞 (0) 思创斯忠实用户-ss思创斯忠实用户-ss 0 0 生成海报


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3