0
我想检测第1行中的字符串是否存在于文件名中,而不会将其与第2行中的字符串混淆,因为第1行中的文本是第2行中文本的子字符串。我尝试了下面的代码,但它没有正确检测到它。搜索在powershell中包含换行符的字符串
我的PowerShell脚本:
$s1 = 'Hello world'
$s2 = "`n"
[int]$result = Get-Content filename | Select-String $s1+$s2 -quiet
Write-Host "result : " $result
凡文件名的内容是:
"line1: xxxxxx Hello world"
"line2: yyyyyy Hello world and some more text"
已解决。非常感谢你 – Willeman