删除所有逗号后的空格 [英] Removing spaces after all commas

查看:125
本文介绍了删除所有逗号后的空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 CSV 文件,每个逗号后都有一个空格.我希望删除每个逗号后的空格,然后尝试以下操作:

I have a a CSV file which has a space after every comma. I wish to remove the space after every comma and I try something like:

sed -e 's/ ,/,/g' local.csv > localNoSpaces.csv

但这只会删除每行第一个逗号之后的空格.如何删除所有逗号后的空格?

But this only removes the space after the first comma on each line. How do I remove the space after all commas?

谢谢.

推荐答案

以防万一空格不是空格而是制表符和空格你可以使用

Just in case that the spaces are not spaces but tabs and spaces you could use

 sed -e 's/\s\+,/,/g' local.csv > localNoSpaces.csv

或者如果它们在每个逗号之后使用

or if they are after each comma use

 sed -e 's/,\s\+/,/g' local.csv > localNoSpaces.csv

这篇关于删除所有逗号后的空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆