2.txt
“platform”:“iPhone”,“report_attrs”:{“SKU”:“XYZ123”,“单价”: “32.25”,“数量”:“3”}
“platform”:“android”,“report_attrs”:{“SKU”:“XYZ123”,“单价”: “32.25”,“数量”:“3”}
我想将,*:*{
替换为,
O / P:
“平台”:“iPhone”,“SKU”:“XYZ123”,“单价”:“32.25”,“数量”:“3”}
“platform”:“android”,“SKU”:“XYZ123”,“单价”:“32.25”,“数量”: “3”}
这是我试过的:
sed s/,*:*{/,/g 2.txt
答案 0 :(得分:0)
,*
表示匹配零个或多个,
,:*
表示匹配零个或多个:
符号。
通过sed,
$ sed 's/,[^:]*:[^{]*{/,/' file
"platform": "iPhone","SKU": "XYZ123","Unit Price": "32.25","Qty": "3"}
"platform": "android","SKU": "XYZ123","Unit Price": "32.25","Qty": "3"}
OR
$ sed 's/,[^{]*{/,/' file
"platform": "iPhone","SKU": "XYZ123","Unit Price": "32.25","Qty": "3"}
"platform": "android","SKU": "XYZ123","Unit Price": "32.25","Qty": "3"}