Mailing List Archive
tlug.jp Mailing List tlug archive tlug Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][tlug] Joining lists on the command line
- Date: Fri, 11 Sep 2009 14:56:11 +0900
- From: Leo Howell <leo@example.com>
- Subject: [tlug] Joining lists on the command line
- User-agent: Mutt/1.4.2.2i
Hi TLUG, Say you have a list of items, one per line, such as the output of "ls", "grep" or whatever. As an example, how about: seq 5 which just gives the numbers 1 to 5. What's the most unixy way to put them into a comma-separated list using the command line? The command I used (adjusted for the example above) was seq 5 | xargs -n1 -I$ echo -n $, Which almost works, except there is a trailing comma and no newline. I know this can be fixed with a slightly longer command, but it served my purposes. While writing this email, I came up with seq 5 | tr '\n' , which is shorter, but provides the same output. Can anyone think of something better? I feel like I'm missing something obvious - and there's already a different utility called "join". Leo
- Follow-Ups:
- Re: [tlug] Joining lists on the command line
- From: Edward Middleton
- Re: [tlug] Joining lists on the command line
- From: BALUTA Chris
- Re: [tlug] Joining lists on the command line
- From: David Shanahan
Home | Main Index | Thread Index
- Prev by Date: Re: [tlug] ICFP at Next TLUG Meeting
- Next by Date: Re: [tlug] Joining lists on the command line
- Previous by thread: Re: [tlug] Network design
- Next by thread: Re: [tlug] Joining lists on the command line
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links