powershell 查找目录中所有yml类型文件包含 shitian的文件

您可以通过一下几种方式查找:

1,Get-ChildItem -Recurse -file -Filter "*.yml"|Select-String -Pattern "7990"|Format-List path,linenumber,Line

返回结果:Path       : D:\mth_v2.0\v2.0-java\tt-config\src\main\resources\application.yml

LineNumber : 2

Line       :   port: 7990


2,Get-ChildItem -Recurse -file -Filter "*.yml"|Select-String -Pattern "7990" -List|Select-Object -Unique path


返回: Path

----

D:\mth_v2.0\v2.0-java\tt-config\src\main\resources\application.yml


3,Get-ChildItem -Path "D:\mth20\java" -Recurse -Filter *.yml | 

ForEach-Object {

  if ($_ | Select-String -Pattern "7790") {

    Write-Host "Found in: $($_.FullName)"

  }

}

返回:Found in: D:\mth_v2.0\v2.0-java\tt-config\src\main\resources\application.yml

请先 登录 后评论
  • 0 关注
  • 0 收藏,74 浏览
  • 每天惠23 提出于 2025-05-13 13:59

相似问题