2016-08-14 120 views
-1

我有一個長字符串,但我只對兩個變量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://stackoverflow.com/editing-help)。 – Cyrus

回答

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