当数据用 |] 分隔时,使用 Uniq 实用程序从列表中获取唯一值



我有一个值列表,其中可能包含特殊字符,所有类型的字符。

jusewe@somemail.com
Denver Occupy|another name|metadata
another name
metadata

我需要一种在linuxsedawk中使用uniq实用程序作为输出的方法:上面列表中的唯一值:

jusewe@somemail.com
Denver Occupy
another name
metadata

我尝试过的:

uniq -u test

uniq 只有在重复行相邻时才有效

将给出排序的 Uniq 值

sort -u test

编辑:在|上拆分行

tr '|' 'n' < test | sort -u
sed -ne "s/|/n/p" test |sort |uniq

享受

最新更新