您可以通过一下几种方式查找:
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