Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Remove the comma in the first column in .csv file using bash code

I have a data as follows;
12432,20230

I want to remove the comma and replace it with space and want the output as follows;
12432 20230

I used the following code;

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

sed ’s/,/ /g’ file.csv > file.geno

but it gives error as;

sed: -e expression #1, char 1: unknown command: `�’

>Solution :

Your code is using "smart quotes", , instead of single quotes, ', just fix that and your syntax error will go away, i.e. instead of:

sed ’s/,/ /g’ file.csv > file.geno

use:

sed 's/,/ /g' file.csv > file.geno

You don’t need the g at the end btw since you only have 1 comma in your input.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading