Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #195157
| From | Curt <curty@free.fr> |
|---|---|
| Newsgroups | linux.debian.user |
| Subject | Re: List words separated by comma and without duplicates |
| Date | 2018-04-29 22:20 +0200 |
| Message-ID | <vK0XD-1FV-3@gated-at.bofh.it> (permalink) |
| References | <vJYCt-8cM-5@gated-at.bofh.it> <vJZfc-hl-7@gated-at.bofh.it> |
| Organization | Unorganized |
On 2018-04-29, <tomas@tuxteam.de> <tomas@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
Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
List words separated by comma and without duplicates Rodolfo Medina <rodolfo.medina@gmail.com> - 2018-04-29 19:50 +0200
Re: List words separated by comma and without duplicates rhkramer@gmail.com - 2018-04-29 20:00 +0200
Re: List words separated by comma and without duplicates "Antonio A. Rendina" <arendina13@gmail.com> - 2018-04-29 20:20 +0200
Re: List words separated by comma and without duplicates David Margerison <deltam@electrosonics.com.au> - 2018-04-30 01:40 +0200
Re: List words separated by comma and without duplicates Bob McGowan <ramjr0915@gmail.com> - 2018-05-01 05:50 +0200
Re: List words separated by comma and without duplicates "Antonio A. Rendina" <arendina13@gmail.com> - 2018-04-29 20:30 +0200
Re: List words separated by comma and without duplicates Abdullah Ramazanoglu <ar018@yahoo.com> - 2018-04-29 20:40 +0200
Re: List words separated by comma and without duplicates <tomas@tuxteam.de> - 2018-04-29 20:30 +0200
Re: List words separated by comma and without duplicates Curt <curty@free.fr> - 2018-04-29 22:20 +0200
Re: List words separated by comma and without duplicates <tomas@tuxteam.de> - 2018-04-29 22:40 +0200
Re: List words separated by comma and without duplicates Gene Heskett <gheskett@shentel.net> - 2018-04-30 00:30 +0200
[OT - long running shows] Re: List words separated by comma and without duplicates Richard Hector <richard@walnut.gen.nz> - 2018-04-30 02:30 +0200
Re: [OT - long running shows] Re: List words separated by comma and without duplicates Gene Heskett <gheskett@shentel.net> - 2018-04-30 03:00 +0200
Re: [OT - long running shows] Re: List words separated by comma and without duplicates Richard Hector <richard@walnut.gen.nz> - 2018-04-30 03:30 +0200
Re: [OT - long running shows] Re: List words separated by comma and without duplicates Gene Heskett <gheskett@shentel.net> - 2018-04-30 05:00 +0200
Re: List words separated by comma and without duplicates Rodolfo Medina <rodolfo.medina@gmail.com> - 2018-05-18 21:00 +0200
Re: List words separated by comma and without duplicates <tomas@tuxteam.de> - 2018-05-18 21:20 +0200
csiph-web