我有一个像下面这样的字符串:
engineer,doctor,"987,345,123",engineer
我想在 Unix 中将其更改为以下内容:
engineer,doctor,"987345123",engineer
答案1
使用以下命令删除输入中每个 CSV 记录的第三个字段中的所有逗号gsub()
使用以下操作磨坊主。假设输入数据集是无标头的。
$ mlr --csv -N put '$3 = gsub($3, ",", "")' file
engineer,doctor,987345123,engineer
保留原始引文,即使它们不再需要:
$ mlr --csv -N --quote-original put '$3 = gsub($3, ",", "")' file
engineer,doctor,"987345123",engineer