gpt4 book ai didi

powershell - 删除数组重复项,但保留原始

转载 作者:行者123 更新时间:2023-12-03 00:25:49 26 4
gpt4 key购买 nike

我有一个数组:

Name
----
hi
hello
hello

我想删除所有重复的内容-但请保留至少一份原件。所以输出应该像

Name
----
hi
hello

最佳答案

Select-Object-唯一

Specifies that if a subset of the input objects has identical properties and values, only a single member of the subset will be selected.

This parameter is case-sensitive. As a result, strings that differ only in character casing are considered to be unique.



示例5:从数组中选择唯一字符
PS C:\>"a","b","c","a","a","a" | Select-Object -Unique

a
b
c

此命令使用 UniqueSelect-Object参数从字符数组中获取唯一字符。

关于powershell - 删除数组重复项,但保留原始,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40826956/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com