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

Loop to remove inverted commas (") in a dataset in bash

I would like to find a way to use an iterative loop (for or while) to remove quotes (") from a dataset like the following:

"Macao,""China,Macao Special Administrative Region"",MAC

I know that there is the following way to remove them, which is actually more efficient, but it is important that it is an iterative statement in bash

sed -i -e 's/"//g' file.csv

Any idea?

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

>Solution :

You can use while read -r to read the lines. Use Parameter Expansion to remove the double quotes.

while read -r line ; do printf '%s\n' "${line//\"}" ; done < 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