我使用以下代码在一个非常大的csv文件中查找包含字符串的行,然后将字符串所在的行打印到一个.log文件。
我正在使用下面的代码...
$fileContents = Get-Content $testReport -TotalCount 1
$fileContents += Get-Content $testReport -ReadCount 1000 | ForEach {$_ -match $myString}
$fileContents | Set-Content 'C:\Temp\test1.log'而不是获得以下内容:
firstLine
line
line
line我得到了这个:
firstLine
linelineline这方面的任何帮助都是很好的。
发布于 2015-12-19 02:47:52
看起来这是最好的方法..。
Import-Csv $testReport |
Where-Object {$_.columnName -eq $myString} |
Export-Csv 'C:\Temp\test1.log' -NoTypeInformation -Forcehttps://stackoverflow.com/questions/34361790
复制相似问题