【发布时间】:2018-06-27 10:53:35
【问题描述】:
我不是 PowerShell 专家。我正在尝试在文件中搜索多行字符串,但没有得到想要的结果。
这是我的代码:
$search_string = @("This is the first line`nThis is the second line`nThis is the third line")
$file_path = "log.txt"
$ret_string = @(Get-Content -Path $file_path | Where-Object{$_.Contains($search_string)}).Count
Write-Host $ret_string
$ret_string 设置为0,尽管"log.txt" 包含与$search_string 完全相同的内容。
【问题讨论】:
标签: powershell