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

Re: List words separated by comma and without duplicates

Rodolfo Medina <rodolfo.medina@gmail.com> writes:

> Suppose I have a file made by a list of names and surnames, e.g.:
> Arvo Part
> Harold Pinter
> Lucio Battisti
> Antonio Amurri
> Eduardo De Filippo
> Eduardo De Filippo
> and that I want them listed all on one line, separated by a comma and without
> duplicates, i.e.:
> Arvo Part, Harold Pinter, Lucio Battisti, Antonio Amurri, Eduardo De Filippo
> How can I do that with proper Unix commands?

Thanks to all who helped.  I adopted Tomas' solution:

perl -e 'while(<STDIN>) {chop; push(@result, $_) unless $seen{$_}++;} print(join(", ", @result), "\n");' < authors.auth > authors.txt

It seems to suit my needs.



Reply to: