$ echo -e 'a b\nc d\ne f\n' | xargs | tr ' ' ','
a,b,c,d,e,f


Robert Citek wrote:


Is there a way to tell xargs to use a field separator other than a space?

xargs is a wonderful tool for transforming a list of data from standard input into a list of arguments to a command. For example, here's a way to use xargs to turn rows of data into one long column of data:

$ echo -e 'a b\nc d\ne f\n'
a b
c d
e f

$ echo -e 'a b\nc d\ne f\n' | xargs echo

Is there some options I could pass to xargs that would substitute, say a comma instead of a space for the field separator? I can mimic what I want by passing the above output to sed:

$ echo -e 'a b\nc d\ne f\n' | xargs echo | sed -e 's/ /,/g'
a,b,c,d,e,f

Can anyone think of a "better" way?

Regards,
- Robert
http://www.cwelug.org/downloads
Help others get OpenSource software.  Distribute FLOSS
for Windows, Linux, *BSD, and MacOS X with BitTorrent

_______________________________________________
CWE-LUG mailing list
http://www.cwelug.org/    [email protected]
http://lists.firepipe.net/listinfo/cwe-lug


--
Ed Howland
WDT Solutions, LLC.
[EMAIL PROTECTED]
(314) 962-0766

_______________________________________________
CWE-LUG mailing list
http://www.cwelug.org/ [email protected]
http://lists.firepipe.net/listinfo/cwe-lug

Reply via email to