Easily change file separator

Quick Linux tip to efficiently change file separators in large CSV files using the sed command - transform commas to spaces or any delimiter in seconds, even for 500MB+ files.

Easily change file separator
Photo by Mika Baumeister / Unsplash

You may already have found yourself in front of a huge csv file to be processed. Five minutes after having started working, you realize that you want spaces instead of commas in your file. Only problem, the file is 500 megabytes big.

Do you run Linux ? In this case, your case will be solved in 10 seconds (who said as usual ? :p).

Simply open a console and run this line


sed -e $"s/,/\ /g" myfile > newfile

or more generally,


sed -e $"s/old_separator/new_separator/g" myfile > newfile

If not, well you may want to think about switching then :)

Thanks to Frafra for the tip ;)