只有在引号之间替换空格 [英] replace spaces only in between quotation marks

查看:109
本文介绍了只有在引号之间替换空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从日志文件行:

field 1234 "text in quotes" 1234 "other text in quotes"

我想换成空格引号之间,所以我可以比使用空格作为分隔符提取列。因此,其结果可能是类似

I would like to replace spaces in between quotes, so I could than extract columns using space as delimiter. So the result could be something like

field 1234 "text@in@quotes" 1234 "other@text@in@quotes"

我无法找出自己的sed工作正则表达式。
非常感谢帮助。
马丁

I was not able to find out working regex for sed myself. Thanks a lot for help. Martin

推荐答案

通过这个awk命令管你的日志文件:

Pipe your log file through this awk command:

awk -F\" '{OFS="\"";for(i=2;i<NF;i+=2)gsub(/ /,"@",$i);print}'

这篇关于只有在引号之间替换空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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