Hi, Please read the whole thread.
I have been working on this script below. It works fine, feel free to copy and test with the INPUT File below as well.
example:
PACKET DATA PROTOCOL CONTEXT DATA
APNID PDPADD EQOSID VPAA PDPCH PDPTY PDPID
10 8 NO 8-0 IPV4 1
1 8 NO 8-0 IPV4 2
2 8 NO 8-0 IPV4 3
END
What I need to get is the first column between the pattern
PACKET DATA PROTOCOL CONTEXT DATA and
END
for this case , that will be
OUPUT
63728153,714011000635895,OBO-0,OBR-2,OBI-0,TS21-1,OICK-30,TICK-31,10,1,2
I have copied the output from the script.
****************************************
SCRIPT
BEGIN { RS="hgsdp" }
{ cat[1] = "OBO"
cat[2] = "OBR"
cat[3] = "OBI"
cat[4] = "TS21"
}
{
if ($12 ~ /NOT/ ) printf "\n" substr ($1,16,8) "," "NOT_CONNECTED" ;
else printf "\n" substr ($1,16,8) "," $12
}
{
for (x = 1; x <= 4; x++)
if (match($0,cat[x])) printf "," substr($0, RSTART, RLENGTH+2)
else { printf "," cat[x]"-0" }
if (match($0,"OICK")) printf "," substr($0, RSTART, RLENGTH+3)
if (match($0,"TICK")) printf "," substr($0, RSTART, RLENGTH+3)
}
****************************************
INPUT FILE
<hgsdp:msisdn=50763728153,all;
HLR SUBSCRIBER DATA
SUBSCRIBER IDENTITY
MSISDN IMSI STATE AUTHD
50763728153 714011000635895 CONNECTED AVAILABLE
PERMANENT SUBSCRIBER DATA
SUD
CAT-10 DBSG-1 TSMO-0 OBR-2
OSB4-1 TS11-1 TS21-1 TS22-1
BS2G-1 BS3G-1 REDMCH-1 OFA-1
PWD-0000 EMLPP-1 DEMLPP-5 MEMLPP-5
OICK-30 TICK-31 CFU-1 BAOC-1
BOIC-1 BOIEXH-1 BAIC-1 BICRO-1
CAW-1 SOCFU-0 SOCB-1 SOCLIP-0
SODCF-0 SOSDCF-7 HOLD-1 MPTY-1
CLIP-1
SCHAR-8-0
AMSISDN BS BC
NONE
PACKET DATA PROTOCOL CONTEXT DATA
APNID PDPADD EQOSID VPAA PDPCH PDPTY PDPID
10 8 NO 8-0 IPV4 1
1 8 NO 8-0 IPV4 2
2 8 NO 8-0 IPV4 3
END
<hgsdp:msisdn=50763780269,all;
****************************************
OUPUT
63728153,714011000635895,OBO-0,OBR-2,OBI-0,TS21-1,OICK-30,TICK-31
63780269,714011000639632,OBO-0,OBR-2,OBI-0,TS21-1,OICK-10,TICK-18
****************************************