首页 > 解决方案 > Delete last character from line that contains specific word

问题描述

I want to delete the last comma from a line that contains a specific string/word

I have tried a couple examples with sed, but none provided the correct result.

{
    "src4_addr" : "10.10.10.10", 
    "dst4_addr" : "11.11.11.11",
    "in_bytes" : 70,
},

I would like to eliminate the comma from the line that contains the word in_bytes.

Expected result:

{
    "src4_addr" : "172.27.90.18", 
    "dst4_addr" : "172.27.90.131",
    "in_bytes" : 70
},

标签: bashawksed

解决方案


也许这样的事情会做:

sed '/in_bytes/ s/,//g'

示例:https ://ideone.com/3hEXBY


推荐阅读