与Linux等效的Windows:查找-name

时间:2019-03-08 14:42:09

标签: windows powershell command-line command-prompt

我试图在Linux Ubuntu中知道CLI中的命令,但是我需要在Microsoft中应用它。

此外,我正在尝试查找具有特定名称的文件夹中的所有文件。特别是,我尝试查找名称中包含“ test”一词的所有文件。 这是我在Linux中知道的命令:

find \home\user\data -name '*test*'

有人知道Windows命令行中的等效语言吗?

谢谢!

3 个答案:

答案 0 :(得分:3)

您将寻找 Get-ChildItem

Get-ChildItem C:\Test -Filter "*test*"

答案 1 :(得分:1)

在powershell中,您可以使用Get-ChildItem查找文件和文件夹

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/get-childitem?view=powershell-6

如果要使用正则表达式,可以将get-childitem与Select-string或where-object cmdlet组合

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/select-string?view=powershell-6

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/where-object?view=powershell-6

Get-ChildItem -Path "c:\" -Recurse | select-string -pattern "Regex"

Get-ChildItem -Path "c:\" -Recurse | Where-Object -FilterScript {$_.name -match "regex"}

答案 2 :(得分:0)

您正在寻找“ dir”命令。要完成与原始搜索相同的操作,您可以使用

dir \home\user\data "*test*"
相关问题