home | list info | list archive | date index | thread index

Re: [OCLUG-Tech] sed

It would seem Chris h, on Tue, Nov 18, 2008 at 06:21:02PM -0500, wrote:
> Greets:
> 
> Small problem and was wondering is some one can help. I have tabular data that 
> is separated by spaces and want to convert it to csv format. I did some 
> digging and found the necessary sed scripts to convert from cvs to space 
> delimited text but not the other way around. 
> 
> sed -e :a -e 's/\(.*[0-9]\)\([0-9]\{3\}\)/\1,\2/;ta' 
> ref: http://student.northpark.edu/pemente/sed/sedfaq4.


You could also try the tr command:

tr '\t' ',' < infile > outfile # will convert all tabs to commas.

-Ross


references