获得长字符串中的特定子字符串

问题描述:

我有一个长字符串,但我只对两个变量statecallee_contact及其值有兴趣。获得长字符串中的特定子字符串

dialog :: hash = 2089:3329 state :: 4 ref_count :: 2 timestart :: 1471200133 timeout :: 130932077 callid :: TVO3l_3-n-gAYdlXqlFHGg .. from_uri :: sip:[email protected]; transport = UDP from_tag :: c279ef54 caller_contact :: sip:[email protected]:58055; transport = UDP caller_cseq :: 1 caller_route_set :: caller_bind_addr :: udp:192.168.10.5:5060 callee_bind_addr :: udp:192.168.10.5:5060 to_uri :: sip:[email protected]; transport = UDP to_tag :: yBr2aQBNHSZge callee_contact :: sip:[email protected]:5080; transport = udp callee_cseq :: 0 callee_route_set :: dialog :: hash = 3480:8766 state: :2 ref_count :: 2 timestart :: 1471200092 timeout :: 130932077 callid :: - 8J4085lgGwUqLlr0LUEw .. from_uri :: sip:[email protected]; transport = UDP from_tag :: 7d327878 caller_contact :: sip:[email protected] :58055; transport = UDP caller_cseq :: 2 caller_route_set :: caller_bind_addr :: udp:192.168.10.5:5060 callee_bind_ad dr :: udp:192.168.10.5:5060 to_uri :: sip:[email protected]; transport = UDP to_tag :: X2y98UtHmg9Xj callee_contact :: sip:[email protected]:5080; transport = udp callee_cseq :: 0 callee_route_set: :

结果应该如下所示。

状态:: 4 callee_contact :: SIP:[email protected]:5080;运输= UDP状态:: 2 callee_contact :: SIP:[email protected]:5080;运输= UDP

任何帮助非常感谢。 谢谢。

+0

从哪里来的文字? – RomanPerekhrest

+0

嗨,这个2调用我从Kamailio获得的对话信息。 – user3310052

+0

请查看[editing-help](http://*.com/editing-help)。 – Cyrus

grep -o -e "state:: [^ ]*" -e "callee_contact:: [^ ]*"