Reputation: 975
If I have an array in bash like:
x=(1 1 1 2 2 3 3 4 5 5)
How do you determine and print the value that occurs only once?
Upvotes: 3
Views: 716
Reputation: 88553
Try this:
printf "%s\n" "${x[@]}" | sort | uniq -u
Output:
4
Upvotes: 4