[英]Output Group-Object Column to File
使用Powershell,我创建了这样的数据集。
Count Name Group
----- ---- -----
2 108005 {108005, 108005}
2 114763 {114763, 114763}
2 115826 {115826, 115826}
2 115925 {115925, 115925}
2 117435 {117435, 117435}
2 114152 {114152, 114152}
2 117093 {117093, 117093}
使用此代码。
$check = Get-Content $file | Group | Where {$_.count -gt 1}
我使用代码检查重复项,但无法弄清楚如何将“名称”列输出到仅包含名称的纯txt文件中的列表。 似乎没有太多有关如何执行此操作的文档。 这有可能吗?
使用ForEach-Object
或Select-Object -ExpandProperty
:
$duplicates = Get-Content $file | Group | Where {$_.count -gt 1} |Select-Object -ExpandProperty Name
由于除了名称之外不需要任何其他名称,因此可以避免使用-NoElement
开关参数在分组过程中生成单个集合:
$duplicates = Get-Content $file | Group -NoElement | Where {$_.count -gt 1} |Select-Object -ExpandProperty Name
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.