I have a list of words with spaces in them..would like to substitute the spaces with commas
AUTHOR
Any unix experts here
these words are horizontal, not vertical so i cant use awk
maintain space with comma or replace space with comma?
replace with
either way, are you familiar with sed?
we all are. Java, C, C++,C#,PHP,Python,Objective-C,Perl,JavaScript,Lisp,Ada certified
sed -e 's/[[:space:]]+/,/gbye.
voltaic quote:I actually used sed s/\ /,/g oldfile >newfilesed -e 's/[[:space:]]+/,/g
bye.
voltaic quote:gonan try, if it doesnt work, diesed -e 's/[[:space:]]+/,/g
bye.
suresh quote:mine worky too fyi
gonan try, if it doesnt work, die
Louis2rich quote:
I actually used sed s/\ /,/g oldfile >newfile
Louis2rich quote:$ cat test
mine worky too fyi
a b c d e f g h i j k l m n o p
$ sed s/\ /,/g test >test1
$ cat test1
a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p
Louis2rich quote:not working ;/
mine worky too fyi
suresh quote:that's unfortunate
not working ;/

sed 's/[ ]\+/,/g'voltaic quote:tryinsed 's/[ ]\+/,/g'
sed 's/[ >\+/,/g' vmfail.out
epo-pou-01 rsm-pou-01 tpm-pou-01 UI1PAWB004E UI1P1AP001E UI1T1AP003X UI1T1AP004X UI1T1AP005X UI1T1DB002X dc-pou-01 pttm-pou-01 rsm-pou-02 rsm-pou-03 serp-pou-01 UI1PAWB013X UI1PAAP001E UI1PAAP002E UI1PAAP003E UI1PAAP004E ui1paap005e UI1PAAP006E UI1PAWB001E UI1PAWB002E UI1PAWB003E tpm-pou-01 tpm-pou-01 serp-pou-01 ui1paap005e UI1PAAP006E ui1pawb001e ui1paap005e UI1PAAP001E
epo-pou-01 rsm-pou-01 tpm-pou-01 UI1PAWB004E UI1P1AP001E UI1T1AP003X UI1T1AP004X UI1T1AP005X UI1T1DB002X dc-pou-01 pttm-pou-01 rsm-pou-02 rsm-pou-03 serp-pou-01 UI1PAWB013X UI1PAAP001E UI1PAAP002E UI1PAAP003E UI1PAAP004E ui1paap005e UI1PAAP006E UI1PAWB001E UI1PAWB002E UI1PAWB003E tpm-pou-01 tpm-pou-01 serp-pou-01 ui1paap005e UI1PAAP006E ui1pawb001e ui1paap005e UI1PAAP001E
the > is actually sed 's/[ >
fck
use Modern::Perl;
use Tie::File;
my @tied_array;
tie @tied_array, 'Tie::File', 'test.txt', autochomp => 1;
s/\s+/,/g for @tied_array;
nom nom nom
Quick reply
Sign in to post a message.Times shown in Eastern Time (ET).
