[Novalug] remove commas from .csv files

Nino Pereira pereira at speakeasy.net
Wed Mar 10 21:39:18 EST 2010


FYI....

Some time ago I had the following question:

In a directory I have a slew of comma-separated files, each with two columns.
In this same directory, which has nothing else, I want to make new files
wherein the commas are replaced by spaces, and the original file name
foo.csv becomes foo.dat.

I got various very helpful suggestions. The one that worked the best
was by Jon LaBadie:

 >   for file in *.csv
 >   do
 >   	sed 's/","/" "/'  $file > ${file%.csv}.dat
 >   done
 >

It worked perfectly. I put it in a file called 'csvtodat',
which I made executable and put in /usr/local/bin.

Thank you Jon, and all others who replied.

Nino



More information about the Novalug mailing list