PowerShell过滤文件中的重复内容
Get-Content -Path E:\test11\data.txt | Sort-Object | Get-Unique
源文件:
AA0001 2014-06-30 15:27:13.073 AA0001 2014-06-30 15:27:13.073 AA0001 2014-06-30 15:27:13.073 AA0002 2014-06-30 15:27:30.607 AA0002 2014-06-30 15:28:00.467 AA0003 2014-06-30 15:28:20.297 AA0003 2014-06-30 15:28:20.297
过滤后:
AA0001 2014-06-30 15:27:13.073 AA0002 2014-06-30 15:27:30.607 AA0002 2014-06-30 15:28:00.467 AA0003 2014-06-30 15:28:20.297
过滤后,另存为新的文件,可以这样:
Get-Content -Path E:\test11\data.txt | Sort-Object | Get-Unique | Out-File -FilePath E:\test11\NewData.txt