Jul 7, 2004 #1 valle70 IS-IT--Management Jun 11, 2004 6 DK Hi How can i convert a list to a string? I have following list: node1 node2 node3 node4 And i would like to convert this list to: node1, node2, node3, node4 How do i do this? Regards Valle70
Hi How can i convert a list to a string? I have following list: node1 node2 node3 node4 And i would like to convert this list to: node1, node2, node3, node4 How do i do this? Regards Valle70
Jul 7, 2004 #2 vgersh99 Programmer Jul 27, 2000 2,146 US Code: nawk -v RS='' -v OFS=',' '$1=$1' file vlad +----------------------------+ | #include<disclaimer.h> | +----------------------------+ Upvote 0 Downvote
Code: nawk -v RS='' -v OFS=',' '$1=$1' file vlad +----------------------------+ | #include<disclaimer.h> | +----------------------------+
Jul 7, 2004 1 #3 ChrisCarroll Programmer Oct 10, 2000 177 You can use tr : tr '\n' ',' < sourcefile will translate all newlines in the file to commas. I suspect you'll get a better answer from an awk user though... Upvote 0 Downvote
You can use tr : tr '\n' ',' < sourcefile will translate all newlines in the file to commas. I suspect you'll get a better answer from an awk user though...
Jul 7, 2004 #4 ChrisCarroll Programmer Oct 10, 2000 177 There you are you see. In the time it took me to type "you'll get a better answer from an awk user" ... Upvote 0 Downvote
There you are you see. In the time it took me to type "you'll get a better answer from an awk user" ...
Jul 7, 2004 #5 vgersh99 Programmer Jul 27, 2000 2,146 US vlad +----------------------------+ | #include<disclaimer.h> | +----------------------------+ Upvote 0 Downvote
Jul 7, 2004 1 #6 olded Programmer Oct 27, 1998 1,065 US Hi: How about using xargs? cat file|xargs Regards, Ed Upvote 0 Downvote
Jul 7, 2004 #7 Ygor Programmer Feb 21, 2003 623 GB In ksh... [tt] list=$(<file1) [/tt] Or perhaps... [tt] list=$(echo $(<file1)|sed 's/ /, /g')[/tt] Upvote 0 Downvote
Jul 7, 2004 Thread starter #8 valle70 IS-IT--Management Jun 11, 2004 6 DK Hi Thanks for all your answears. It seems there is serveral ways to do this. Regards Valle70 Upvote 0 Downvote