
Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [tlug] Joining lists on the command line
Leo Howell wrote:
 
> What's the most unixy way to put them into a comma-separated list using 
> the command line?
   Well, I think almost by definition there isn't a 'most
unixy' way to do much of anything, which is one of the fun things
about the unix command line. 
   But, how about this:  echo `<your command>` | sed -e 's/ /,/g'
 For example, say ls gives this:
 myprompt> ls
afile  bfile  cfile  dfile  theLastFile
 myprompt> echo `ls` | sed -e 's/ /,/g'
gives:
 afile,bfile,cfile,dfile,theLastFile
 myprompt> echo `seq 1 20` | sed -e 's/ /,/g'
  leads to: 
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20
  Of course, you'll have problems w/spaces if your command
output for one line has spaces in it (e.g. output from grep)...
    -Chris
Home |
Main Index |
Thread Index