[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: List words separated by comma and without duplicates



On Sun, 29 Apr 2018 19:24:12 +0100 Antonio A. Rendina said:

> cat list-file | uniq | sed s/$/,/ | tr '\n' ' '

But uniq eliminates consecutive (neighboring) duplicates only. If, for example,
"Eduardo De Filippo" also occurs at 2nd line, then there would still be 2
separate Eduardo's left. So, sort + uniq is necessary as in,

sort list-file | uniq | sed s/$/,/ | tr '\n' ' '

or you can combine them into one (as tomas already suggested)

sort -u list-file | sed s/$/,/ | tr '\n' ' '

Regards
-- 
Abdullah Ramazanoglu



Reply to: