unique sort contents of a variable

Hi ,

I have

#echo $var1
#hdisk2 hdisk3 hdisk0 hdisk2

Now I need to remove duplicate entries from this . ie. after sorting it should only have

hdisk2 hdisk3 hdisk0 .

I can have these values in a array as well . I understand we can use sort -u to remove the duplicates in a coloumn but here it is row and hence I am stuck :slight_smile:

You can try something like:

new_var=$(echo "$var"|tr " " "\n"|sort|uniq|tr "\n" " ")

Regards

waah , thats gr8 ,

and yeah , this also didthe job , i replaced the uniq with sort -u

new_var=$(echo "$var1"|tr " " "\n"|sort -u|tr "\n" " ")

Thank You