On 2018-04-29, <to...@tuxteam.de> <to...@tuxteam.de> wrote: > >> >> How can I do that with proper Unix commands? > > The "classical": > > tomas@trotzki:/tmp$ cat foo > Arvo Part > Harold Pinter > Lucio Battisti > Antonio Amurri > Eduardo De Filippo > Eduardo De Filippo > > tomas@trotzki:/tmp$ sort -u < foo | sed -e 's/$/,/g' | tr '\n' ' ' > Antonio Amurri, Arvo Part, Eduardo De Filippo, Harold Pinter, Lucio Battisti, > > Note that (a) the list ends with ", " (comma-space) and has no newline at > the end, but I preferred to present a simple proto-solution easier for you > to munge. > > The tr is there because sed goes line-wise and thus can't replace newlines. > Except that it can; you pay for it, though [1], [2]. >
Not knowing anything I came up with (after some research): sort -u < test.txt | tr '\n' ',' No sed. My list has a comma at the beginning as well as at the end, though (with no newline, either). But if we were going to the moon with this I would be economizing that supernumerary process. ;-) -- "Three prisoners were locked in a cell. When the largest of them finished his food, he immediately ate the others. Too bad. An apostrophe in the right place might have prevented a horrible crime." Joe Gunn