${(u)…}
: Deduplicate words
u
expands only the first occurrence of each word, i.e. it does not show duplicates in the result.
Links
Examples
- Deduplicate words of a string
- Output:
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}
1 2
Genius is one percent inspiration and ninety-nine perspiration AND GENIUS INSPIRATION IS NINETY-NINE ONE PERCENT PERSPIRATION
BashSupport Pro is a Zsh IDE with support for ${(u)…} – try it now!