Jul 7, 2004 #1 valle70 IS-IT--Management Joined Jun 11, 2004 Messages 6 Location 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 Joined Jul 27, 2000 Messages 2,146 Location 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 Joined Oct 10, 2000 Messages 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 Joined Oct 10, 2000 Messages 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 Joined Jul 27, 2000 Messages 2,146 Location US vlad +----------------------------+ | #include<disclaimer.h> | +----------------------------+ Upvote 0 Downvote
Jul 7, 2004 1 #6 olded Programmer Joined Oct 27, 1998 Messages 1,065 Location US Hi: How about using xargs? cat file|xargs Regards, Ed Upvote 0 Downvote
Jul 7, 2004 #7 Ygor Programmer Joined Feb 21, 2003 Messages 623 Location 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 Joined Jun 11, 2004 Messages 6 Location DK Hi Thanks for all your answears. It seems there is serveral ways to do this. Regards Valle70 Upvote 0 Downvote