linux - to grep specific set of strings occuring multiple times in a single line -
my system generate lengthy lines in logs of want grep few fields values. tried grep , sed , i'm close.
here, single log line contains multiple channel fields , analysis. how specific channel (occurring more once) single log line contains many such channel information. e.g. here need video channel analysis , it's occurring twice in line.
.......{"channel":{"type": "video","protocol": "dynamic_96","rate": "1999102","packets":{"forwarded":{"total": "570495","rtpandrtcp": "570495","keepalives": "0","unknown": "0"},"keepalives":{"total": "0","assent": "0","h460": "0","stun": "0"},"errors":{"total": "0","media":{"nodestination": "0","invalidtype": "0","filterfailure": "0","mediadiscarded": "0","filter":{"srtp":{"decrypt":{"authentication": "0","decrypt": "0","badrtpheader": "0","fecignored": "0","other": "0"}},"rtp":{"payload":{"rewrite":{"unexpected": "0"}}}}},"assent":{"invalidprobe": "0"},"ip":{"send": "0"}},"analysis":{"duplicate": "0","lost": "4","outoforder": "1","unexpected": "0","jitter": "8","jitterpeak": "48"}},"incoming":{"leg": "bside"},"outgoing":{"leg": "aside"}}},.....................{"channel":{"type": "video","protocol": "dynamic_96","rate": "1617864","packets":{"forwarded":{"total": "407214","rtpandrtcp": "407214","keepalives": "0","unknown": "0"},"keepalives":{"total": "0","assent": "0","h460": "0","stun": "0"},"errors":{"total": "0","media":{"nodestination": "0","invalidtype": "0","filterfailure": "0","mediadiscarded": "0","filter":{"srtp":{"encrypt":{"encrypt": "0","badrtpheader": "0","fecignored": "0","datagramsizeexceeded": "0","other": "0"}},"rtp":{"payload":{"rewrite":{"unexpected": "0"}}}}},"assent":{"invalidprobe": "0"},"ip":{"send": "0"}},"analysis":{"duplicate": "0","lost": "1045","outoforder": "0","unexpected": "957","jitter": "3","jitterpeak": "1143"}},"incoming":{"leg": "aside"},"outgoing":{"leg": "bside"}}},......
i interested in above these 2 channel analysis , throw blah blah (.....) information.
any pointers of great help. !!
to channels line can use:
grep -eo '"channel":{[^{]+({[^}]+})+}'
this output example:
"channel":{"type": "video","protocol": "dynamic_96","rate": "1999102","packets":{"forwarded":{"total": "570495","rtpandrtcp": "570495","keepalives": "0","unknown": "0"},"keepalives":{"total": "0","assent": "0","h460": "0","stun": "0"},"errors":{"total": "0","media":{"nodestination": "0","invalidtype": "0","filterfailure": "0","mediadiscarded": "0","filter":{"srtp":{"decrypt":{"authentication": "0","decrypt": "0","badrtpheader": "0","fecignored": "0","other": "0"}} "channel":{"type": "video","protocol": "dynamic_96","rate": "1617864","packets":{"forwarded":{"total": "407214","rtpandrtcp": "407214","keepalives": "0","unknown": "0"},"keepalives":{"total": "0","assent": "0","h460": "0","stun": "0"},"errors":{"total": "0","media":{"nodestination": "0","invalidtype": "0","filterfailure": "0","mediadiscarded": "0","filter":{"srtp":{"encrypt":{"encrypt": "0","badrtpheader": "0","fecignored": "0","datagramsizeexceeded": "0","other": "0"}}
Comments
Post a Comment