${(u)…}: Deduplicate words

u expands only the first occurrence of each word, i.e. it does not show duplicates in the result.

Examples

Deduplicate words of a string
1
2
3
4
5
6
value="Genius is one percent inspiration and ninety-nine percent perspiration."
IFS=" ."
# deduplicate
echo ${(u)=value}
# deduplicate, upper-case, sort
echo ${(uUo)=value}
Output:
1
2
Genius is one percent inspiration and ninety-nine perspiration 
AND GENIUS INSPIRATION IS NINETY-NINE ONE PERCENT PERSPIRATION
BashSupport Pro 是一款支持 u** 的 **Zsh 集成开发环境 - 立即试用
© 2020–2024 Joachim Ansorg
声明
隐私政策
许可条款