在PowerShell中,我正在阅读一个文本文件.然后我在文本文件上做一个Foreach-Object,我只对那些不包含字符串的行感兴趣$arrayOfStringsNotInterestedIn.
这是什么语法?
   Get-Content $filename | Foreach-Object {$_}
Chr*_*son 43
如果$ arrayofStringsNotInterestedIn是[数组],你应该使用-notcontains:
Get-Content $FileName | foreach-object { `
   if ($arrayofStringsNotInterestedIn -notcontains $_) { $) }
或更好(IMO)
Get-Content $FileName | where { $arrayofStringsNotInterestedIn -notcontains $_}
Mar*_*ill 10
您可以使用-notmatch运算符来获取没有您感兴趣的字符的行.
     Get-Content $FileName | foreach-object { 
     if ($_ -notmatch $arrayofStringsNotInterestedIn) { $) }
| 归档时间: | 
 | 
| 查看次数: | 124461 次 | 
| 最近记录: |