vasil
February 25, 2017, 4:56am
1
Hi,
I need help to grep a specific part of a log file (bold).
[ 13] 24/2/2017-16:57:17.056 frosti-1 M3UA-Tx: }
[ 13] 24/2/2017-16:57:17.056 frosti-1 M3UA-Tx: extensionContainer <Not Present>
[ 13] 24/2/2017-16:57:17.056 frosti-1 M3UA-Tx: imsi <Not Present>
[ 13] 24/2/2017-16:57:17.056 frosti-1 M3UA-Tx: _ellipsis <Not Present>
[ 13] 24/2/2017-16:57:17.056 frosti-1 M3UA-Tx: }
[ 13] 24/2/2017-16:57:17.056 frosti-1 M3UA-Tx: }
[ 13] 24/2/2017-16:57:17.056 frosti-1 M3UA-Tx: }
[ 13] 24/2/2017-16:57:17.056 frosti-1 M3UA-Tx: returnResultLast <Not Present>
[ 13] 24/2/2017-16:57:17.056 frosti-1 M3UA-Tx: returnError <Not Present>
[ 13] 24/2/2017-16:57:17.056 frosti-1 M3UA-Tx: reject <Not Present>
[ 13] 24/2/2017-16:57:17.056 frosti-1 M3UA-Tx: returnResultNotLast <Not Present>
[ 13] 24/2/2017-16:57:17.056 frosti-1 M3UA-Tx: }
[ 13] 24/2/2017-16:57:17.056 frosti-1 M3UA-Tx: }
[ 13] 24/2/2017-16:57:17.056 frosti-1 M3UA-Tx: abort <Not Present>
[ 13] 24/2/2017-16:57:17.056 frosti-1 M3UA-Tx: }
[ 13] 24/2/2017-16:57:17.056 frosti-1 M3UA-Tx: }
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: UDT{
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: SGW: VIP_mk_STP1
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: OPC: 996
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: DPC: 7822
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: SLS: 3
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: Source Address: [Route on: GT] [INC: SSN GT] [ SSN: 8 GT: '38977000103' (4.0.1.4)]
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: Destination Address: [Route on: GT] [INC: SSN GT] [ SSN: 8 GT: '38977000301' (4.0.1.4)]
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: Hop Count: 0
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: Data: 62 68 48 04 85 00 03 17 6b 1a 28 18 06 07 00 11
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: Data: 86 05 01 01 01 a0 0d 60 0b a1 09 06 07 04 00 00
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: Data: 01 00 15 02 6c 44 a1 42 02 01 01 02 01 2e 30 3a
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: Data: 84 07 91 83 79 07 00 03 f1 82 07 91 83 79 48 40
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: Data: 38 f7 04 26 01 8e 09 81 70 38 49 24 f0 00 00 1d
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: Data: d4 b4 7c 1c 6e 83 dc 61 10 5d 5e 26 b7 d3 6c 10
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: Data: 3d 0d a2 cb cb e2 70 b8 fd 03
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: TCAP Message{
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: Opcode 46 Result: No
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: unidirectional <Not Present>
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: begin = {
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: otid = {
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: 85 00 03 17
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: }
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: dialoguePortion = {
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: dialogueAsID = {
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: 00 11 86 05 01 01 01
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: }
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: dialoguePDU = {
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: dialogueRequest = {
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: protocol_version <Not Present>
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: app_context = {
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: name = {
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: 7 Bytes
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: 04 00 00 01 00 15 02
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: }
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: }
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: userInfoExt <Not Present>
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: }
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: dialogueResponse <Not Present>
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: dialogueAbort <Not Present>
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: }
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: }
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: components = {
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: invoke = {
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: invokeID = {
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: 1
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: }
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: linkedID <Not Present>
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: operationCode = {
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: 46
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: }
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: parameter = {
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: 30 3a 84 07 91 83 79 07 00 03 f1 82 07 91 83 79
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: 48 40 38 f7 04 26 01 8e 09 81 70 38 49 24 f0 00
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: 00 1d d4 b4 7c 1c 6e 83 dc 61 10 5d 5e 26 b7 d3
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: 6c 10 3d 0d a2 cb cb e2 70 b8 fd 03
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx:
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: MO_ForwardSM_Arg = {
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: sm_RP_DA = {
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: imsi <Not Present>
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: lmsi <Not Present>
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: roamingNumber <Not Present>
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: serviceCentreAddressDA = {
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: '1.1.38977000301'
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: }
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: noSM_RP_DA <Not Present>
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: }
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: sm_RP_OA = {
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: msisdn = {
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: '1.1.38978404837'
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: }
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: serviceCentreAddressOA <Not Present>
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: noSM_RP_OA <Not Present>
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: }
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: sm_RP_UI = {
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: 38 Bytes
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: 01 8e 09 81 70 38 49 24 f0 00 00 1d d4 b4 7c 1c
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: 6e 83 dc 61 10 5d 5e 26 b7 d3 6c 10 3d 0d a2 cb
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: cb e2 70 b8 fd 03
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx:
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: sms-submit = {
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: tp-rd : 0
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: tp-vpf : 0
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: tp-srr : 0
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: tp-udhi : 0
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: tp-rp : 0
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: tp-mr : 142
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: tp-da : 0.1.078394420
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: tp-pid : 0
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: tp-pid : 0
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: tp-dcs : 0
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: tp-vp : 0
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: tp-udl : 29
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: }
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: }
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: extensionContainer <Not Present>
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: imsi <Not Present>
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: _ellipsis <Not Present>
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: }
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: }
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: }
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: returnResultLast <Not Present>
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: returnError <Not Present>
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: reject <Not Present>
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: returnResultNotLast <Not Present>
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: }
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: }
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: end <Not Present>
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: kontinue <Not Present>
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: abort <Not Present>
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: }
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: }
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: UDT{
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: SGW: VIP_mk_STP1
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: OPC: 996
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: DPC: 7822
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: SLS: 3
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: Source Address: [Route on: GT] [INC: SSN GT] [ SSN: 8 GT: '38977000103' (4.0.1.4)]
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: Destination Address: [Route on: GT] [INC: SSN GT] [ SSN: 8 GT: '38977000301' (4.0.1.4)]
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: Hop Count: 0
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: Data: 62 68 48 04 85 00 03 17 6b 1a 28 18 06 07 00 11
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: Data: 86 05 01 01 01 a0 0d 60 0b a1 09 06 07 04 00 00
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: Data: 01 00 15 02 6c 44 a1 42 02 01 01 02 01 2e 30 3a
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: Data: 84 07 91 83 79 07 00 03 f1 82 07 91 83 79 48 40
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: Data: 38 f7 04 26 01 8e 09 81 70 38 49 24 f0 00 00 1d
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: Data: d4 b4 7c 1c 6e 83 dc 61 10 5d 5e 26 b7 d3 6c 10
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: Data: 3d 0d a2 cb cb e2 70 b8 fd 03
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: TCAP Message{
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: Opcode 46 Result: No
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: unidirectional <Not Present>
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: begin = {
[ 14] 24/2/2017-16:57:17.097 frosti-2 M3UA-Rx: otid = {
Search the file for pattern tp-da : 0.1.078394420
Print all lines before tp-da : 0.1.078394420 till first M3UA-Rx: UDT{ match including.
Print all lines after tp-da : 0.1.078394420 till first M3UA-Rx: } match including.
Any help is greatly appreciated.
The non-interactive text editors are great for this kind of thing. Either of the following should work on any system with a POSIX conforming ed
or ex
:
ed -s file <<-"EOF"
g/tp-da *: *0[.]1[.]078394420/?UDT{?,/M3UA-Rx: }/p
q
EOF
ex -s -c 'g/tp-da *: *0[.]1[.]078394420/?UDT{?,/M3UA-Rx: }/p
q' file
Although not required by POSIX, some systems will allow that ex
command to be written with two -c
options on one line:
ex -s -c 'g/tp-da *: *0[.]1[.]078394420/?UDT{?,/M3UA-Rx: }/p' -c 'q' file
3 Likes
vasil
February 25, 2017, 5:52am
3
30 minutes after my post. Thank you Don for the great answer.
Tested the last command and works.
Alternatives, simple:
awk '1; /M3UA-Rx: }/{print x}' infile | awk '/tp-da. *: 0\.1\.078394420/' RS=
single awk:
awk '/M3UA-Rx: UDT{/{r=$0; next} {r=r RS $0} /tp-da. *: 0\.1\.078394420/{f=1} /M3UA-Rx: }/{if(f)print r; f=r=x}' file
sed:
sed -n '/M3UA-Rx: UDT{/{h;n;}; H; /M3UA-Rx: }/{g; /tp-da. *: 0\.1\.078394420/p;}' file
1 Like
vasil
February 26, 2017, 2:45am
5
Thanks Scrutinizer
Using combination from Don's and yours command, can you advice how to use a variable in sed?
For example:
FILE=ss7;sed -n '/M3UA-Rx: UDT{/{h;n;}; H; /M3UA-Rx: }/{g; /M3UA-Rx.* *01 01 06 a6.*/p;}' $FILE
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: UDT{
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: OPC: 2445
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: DPC: 2085
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: SLS: 13
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: Source Address: [Route on: GT] [INC: SSN GT] [ SSN: 6 GT: '85290240832' (4.0.1.4)]
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: Destination Address: [Route on: GT] [INC: SSN GT] [ SSN: 8 GT: '85290240960' (4.0.1.4)]
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: Hop Count: 0
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: Data: 64 51 49 04 01 01 06 a6 6b 26 28 24 06 07 00 11
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: Data: 86 05 01 01 01 a0 19 61 17 a1 09 06 07 04 00 00
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: Data: 01 00 14 02 a2 03 02 01 00 a3 05 a1 03 02 01 00
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: Data: 6c 21 a2 1f 02 01 01 30 1a 02 01 2d 30 15 04 08
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: Data: 54 04 30 70 00 00 40 f9 a0 09 81 07 91 58 92 20
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: Data: 04 08 f1
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: TCAP Message{
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: Opcode 45 Result: Yes
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: unidirectional <Not Present>
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: begin <Not Present>
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: end = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: dtid = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: 01 01 06 a6
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: dialoguePortion = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: dialogueAsID = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: 00 11 86 05 01 01 01
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: dialoguePDU = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: dialogueRequest <Not Present>
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: dialogueResponse = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: protocol_version <Not Present>
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: app_context = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: name = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: 7 Bytes
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: 04 00 00 01 00 14 02
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: result = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: enuum = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: 0 (accepted)
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: result_source_diagnostic = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: dialogue_service_user = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: enuum = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: 0 (dsu_null)
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: dialogue_service_provider <Not Present>
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: userInfoExt <Not Present>
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: dialogueAbort <Not Present>
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: components = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: invoke <Not Present>
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: returnResultLast = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: invokeID = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: 1
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: result = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: operationCode = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: 45
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: parameter = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: 30 15 04 08 54 04 30 70 00 00 40 f9 a0 09 81 07
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: 91 58 92 20 04 08 f1
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx:
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: RoutingInfoForSM_Res = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: imsi = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: '454003070000049'
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: locationInfoWithLMSI = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: networkNode_Number = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: '1.1.85290240801'
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: lmsi <Not Present>
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: extensionContainer <Not Present>
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: gprsNodeIndicator <Not Present>
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: additional_Number <Not Present>
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: _ellipsis <Not Present>
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: extensionContainer <Not Present>
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: _ellipsis <Not Present>
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: returnError <Not Present>
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: reject <Not Present>
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: returnResultNotLast <Not Present>
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: kontinue <Not Present>
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: abort <Not Present>
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
I would like to change 01 01 06 a6 with variable:
FILE=ss7;OTID=$(ex -s -c 'g/SSN: 6 GT: .85290985144.*/?UDT{?,/M3UA-Tx: }/p' -c 'q' $FILE | awk 'f{print;f=0} /otid/{f=1}' | sed -re 's,\s+, ,g' | cut -d ' ' -f 6-); echo $OTID
01 01 06 a6
The below gives me nothing:
FILE=ss7;OTID=$(ex -s -c 'g/SSN: 6 GT: .85290985144.*/?UDT{?,/M3UA-Tx: }/p' -c 'q' $FILE | awk 'f{print;f=0} /otid/{f=1}' | sed -re 's,\s+, ,g' | cut -d ' ' -f 6-); sed -n '/M3UA-Rx: UDT{/{h;n;}; H; /M3UA-Rx: }/{g; /M3UA-Rx.* *$OTID.*/p;}' $FILE
How to expand $OTID variable in the sed expression?
Please explain to us what you are trying to do. If you are going to use awk
, there is probably no need to also use ex
, cut
, and two invocations of sed
. I'm almost positive that the REs you are using in your search patterns are not doing what you think they are doing (and could match strings that you don't intend for them to match).
An immediate problem is that shell variables are not expanded inside single quoted strings. You could try, using double quotes ( "
) instead of single quotes ( '
) around the operand in the last sed
invocation in your command line and it might work; but unless you intend for all of the <period>s in your REs to match any character (not just a <period>), your command line might not work reliably.
vasil
February 26, 2017, 4:05am
7
Hi Don,
My initial post was to get an idea how to extract different parts of a huge log file.
Thanks to yours and Scrutinizer advises I'm trying to prepare a script to extract all the parts i'm interested in at once. The parts are connected by id string ("otid" or "dtid").
For example the below 2 parts are connected by "otid/dtid" string.
FILE=ss7;ex -s -c 'g/SSN: 6 GT: .85290985144.*/?UDT{?,/M3UA-Tx: }/p' -c 'q' $FILE
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: UDT{
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: SGW: TPC-iSPS11-32
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: OPC: 2085
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: DPC: 2444
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: SLS: 9
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: Source Address: [Route on: GT] [INC: SSN GT] [ SSN: 8 GT: '85290240960' (4.0.1.4)]
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: Destination Address: [Route on: GT] [INC: SSN GT] [ SSN: 6 GT: '85290985144' (4.0.1.4)]
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: Hop Count: 0
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: Data: 62 43 48 04 01 01 06 a6 6b 1a 28 18 06 07 00 11
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: Data: 86 05 01 01 01 a0 0d 60 0b a1 09 06 07 04 00 00
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: Data: 01 00 14 02 6c 1f a1 1d 02 01 01 02 01 2d 30 15
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: Data: 80 07 91 58 92 90 58 41 f4 81 01 ff 82 07 91 58
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: Data: 92 20 04 69 f0
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: TCAP Message{
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: Opcode 45 Result: No
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: unidirectional <Not Present>
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: begin = {
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: otid = {
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: 01 01 06 a6
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: }
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: dialoguePortion = {
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: dialogueAsID = {
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: 00 11 86 05 01 01 01
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: }
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: dialoguePDU = {
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: dialogueRequest = {
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: protocol_version <Not Present>
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: app_context = {
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: name = {
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: 7 Bytes
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: 04 00 00 01 00 14 02
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: }
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: }
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: userInfoExt <Not Present>
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: }
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: dialogueResponse <Not Present>
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: dialogueAbort <Not Present>
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: }
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: }
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: components = {
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: invoke = {
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: invokeID = {
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: 1
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: }
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: linkedID <Not Present>
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: operationCode = {
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: 45
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: }
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: parameter = {
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: 30 15 80 07 91 58 92 90 58 41 f4 81 01 ff 82 07
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: 91 58 92 20 04 69 f0
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx:
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: RoutingInfoForSM_Arg = {
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: msisdn = {
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: '1.1.85290985144'
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: }
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: sm_RP_PRI = {
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: True
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: }
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: serviceCentreAddress = {
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: '1.1.85290240960'
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: }
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: __v1_only_cug_interlock <Not Present>
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: __v1_only_teleserviceCode <Not Present>
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: extensionContainer <Not Present>
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: gprsSupportIndicator <Not Present>
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: sm_RP_MTI <Not Present>
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: sm_RP_SMEA <Not Present>
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: _ellipsis <Not Present>
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: }
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: }
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: }
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: returnResultLast <Not Present>
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: returnError <Not Present>
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: reject <Not Present>
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: returnResultNotLast <Not Present>
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: }
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: }
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: end <Not Present>
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: kontinue <Not Present>
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: abort <Not Present>
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: }
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: }
FILE=ss7;sed -n "/M3UA-Rx: UDT{/{h;n;}; H; /M3UA-Rx: }/{g; /M3UA-Rx.* *01 01 06 a6.*/p;}" $FILE
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: UDT{
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: OPC: 2445
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: DPC: 2085
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: SLS: 13
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: Source Address: [Route on: GT] [INC: SSN GT] [ SSN: 6 GT: '85290240832' (4.0.1.4)]
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: Destination Address: [Route on: GT] [INC: SSN GT] [ SSN: 8 GT: '85290240960' (4.0.1.4)]
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: Hop Count: 0
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: Data: 64 51 49 04 01 01 06 a6 6b 26 28 24 06 07 00 11
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: Data: 86 05 01 01 01 a0 19 61 17 a1 09 06 07 04 00 00
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: Data: 01 00 14 02 a2 03 02 01 00 a3 05 a1 03 02 01 00
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: Data: 6c 21 a2 1f 02 01 01 30 1a 02 01 2d 30 15 04 08
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: Data: 54 04 30 70 00 00 40 f9 a0 09 81 07 91 58 92 20
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: Data: 04 08 f1
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: TCAP Message{
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: Opcode 45 Result: Yes
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: unidirectional <Not Present>
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: begin <Not Present>
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: end = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: dtid = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: 01 01 06 a6
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: dialoguePortion = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: dialogueAsID = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: 00 11 86 05 01 01 01
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: dialoguePDU = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: dialogueRequest <Not Present>
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: dialogueResponse = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: protocol_version <Not Present>
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: app_context = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: name = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: 7 Bytes
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: 04 00 00 01 00 14 02
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: result = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: enuum = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: 0 (accepted)
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: result_source_diagnostic = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: dialogue_service_user = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: enuum = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: 0 (dsu_null)
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: dialogue_service_provider <Not Present>
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: userInfoExt <Not Present>
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: dialogueAbort <Not Present>
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: components = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: invoke <Not Present>
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: returnResultLast = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: invokeID = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: 1
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: result = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: operationCode = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: 45
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: parameter = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: 30 15 04 08 54 04 30 70 00 00 40 f9 a0 09 81 07
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: 91 58 92 20 04 08 f1
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx:
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: RoutingInfoForSM_Res = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: imsi = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: '454003070000049'
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: locationInfoWithLMSI = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: networkNode_Number = {
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: '1.1.85290240801'
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: lmsi <Not Present>
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: extensionContainer <Not Present>
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: gprsNodeIndicator <Not Present>
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: additional_Number <Not Present>
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: _ellipsis <Not Present>
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: extensionContainer <Not Present>
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: _ellipsis <Not Present>
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: returnError <Not Present>
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: reject <Not Present>
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: returnResultNotLast <Not Present>
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: kontinue <Not Present>
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: abort <Not Present>
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
[ 13] 25/2/2017-19:02:07.185 frosti-3 M3UA-Rx: }
What I'm trying to do is after printing the first part, to filter "otid" string 01 01 06 a6
For test:
FILE=ss7; OTID=$(ex -s -c 'g/SSN: 6 GT: .85290985144.*/?UDT{?,/M3UA-Tx: }/p' -c 'q' ss7 | awk 'f{print;f=0} /otid/{f=1}' | sed -re 's,\s+, ,g' | cut -d ' ' -f 6-); echo $OTID
01 01 06 a6
save it as variable and use it in the command for the second part.
FILE=ss7
#Print first part
ex -s -c 'g/SSN: 6 GT: .85290985144.*/?UDT{?,/M3UA-Tx: }/p' -c 'q' $FILE
#Extract otid from first part
OTID=$(ex -s -c 'g/SSN: 6 GT: .85290985144.*/?UDT{?,/M3UA-Tx: }/p' -c 'q' ss7 | awk 'f{print;f=0} /otid/{f=1}' | sed -re 's,\s+, ,g' | cut -d ' ' -f 6-)
#Use otid variable to search for the second part
sed -n '/M3UA-Rx: UDT{/{h;n;}; H; /M3UA-Rx: }/{g; /M3UA-Rx.* *$OTID.*/p;}' $FILE
It is well past my bed time, so I'm not going to try to come up with a solution to your problem right now, but I will note that your final sed
script (if you used double quotes instead of single quotes, as I suggested before) will match:
[ 12] 25/2/2017-19:02:06.996 frosti-3 M3UA-Tx: Data: 62 43 48 04 01 01 06 a6 6b 1a 28 18 06 07 00 11
in addition to matching the otid
and dtid
strings you want it to match. Since you have only shown us two records from your huge file, I have absolutely no idea how many other records might have this (or other) false matches for the way you're using to find pairs of matched records.
It is also interesting to note that the problem presented in post #1 in this thread is apparently unrelated to the problem presented here. Why the misdirect asking for a match on a tp-da
value when what you're really looking for is a shared otid
and dtid
value filtered by part of a Source Address
value? And, what keeps that part of a Source Address
field from appearing in some other record's Source Address
or Destination Address
field? Are you sure the initial value you're looking for doesn't appear in some other field in your file as well?
Once you figure out what the otid
value you're looking for is, do you know if the dtid
value you need to match comes before or after the record containing the otid
value? (If you know it comes after the value you've identified, it sure would be nice to just read your huge file once instead of reading the whole file more than three times.
How big is your "huge" file? Are we talking about megabytes, terabytes, or petabytes? How much memory do you have on your system?
What operating system and shell are you using?
RudiC
February 26, 2017, 6:04am
9
You lost me. Are you looking for records containing
tp-da : 0.1.078394420
and / or SSN: 6 GT: .85290985144
?
And then the otid
value from within those to be matched with a dtid
value? Or any other field's value?
What is the sequence of otid
/ dtid,
otid
always first? Or last?
Should otid
records be printed regardless of dtid
found or not?
How many pairs will occur in one log file? Are they mixed up or in sequence?