ragtag
November 3rd, 2008, 10:02 AM
How do I make all entries in an array unique. I've been trying something like:
my_array=( a b a a c)
unique_array=$(echo $my_array | sort -u)
for a in ${unique_array[@]}; do
echo $a
done
What I'm hopint to get out is:
a
b
c
But what I get is just 'a'.
How would I go about this?
my_array=( a b a a c)
unique_array=$(echo $my_array | sort -u)
for a in ${unique_array[@]}; do
echo $a
done
What I'm hopint to get out is:
a
b
c
But what I get is just 'a'.
How would I go about this?