Hi All,
On my prevoius post I tried to align 3 lines into one, (thanks to PHV) some success. What I am now trying to achive is to , once /DSB/ is found , define what I need from that line ,and then read the next line which starts with +++=, and define $2 then once all defining is done use the printf statement.
My Script
/tools/Chris filename |
awk '{
Here is no problem ---- > if(match($1,"BIL=")){
for (e=1;e<NF;e++){if ($e~/^BIL/){
LA=$(e+4)
{if ($(e+4)==00){
Anum="NULL"
}else{
A_num=$(e+5)
}}}
if($e~/P=65/){
BNUM=$(e+2)
LN=$(e+1)
}
if($e~/P=64/){
DATE=$(e+1)
DUR=$(e+3)
}
if($e~/P=67/){
UN=$(e+1)
}}
hexstr="0123456789abcdef"
newnum=tolower(substr(DUR,5,2) substr(DUR,3,2) substr(DUR,1,2))
YEAR=tolower(substr(DATE,1,2))
MONT=tolower(substr(DATE,3,2))
DAY=tolower(substr(DATE,5,2))
HOUR=tolower(substr(DATE,7,2))
MIN=tolower(substr(DATE,9,2))
SEC=tolower(substr(DATE,11,2))
OPE=tolower(substr(UN,5,2) substr(UN,3,2) substr(UN,1,2))
LEN=tolower(substr(LN,1,2))
ALEN=tolower(substr(LA,1,2))
AN=tolower(substr(Anum,1,15))
decnum12 = 0
slen_bn = length(LEN)
#do some stuff here ---------->
}
printf ("%11s %.2d-%.2d-%.2d %.2d:%.2d:%.2d %18s %10d (%d)\n",AN,decnum6,decnum5,decn
um1,decnum2,decnum3,decnum4,BN,decnum,decnum7)
}
}
}else{
Here is no problem ---- > if(match($1,"DSB=")){
hexstr="0123456789abcdef"
newnum=tolower(substr($9,3,2) substr($9,1,2))
YEAR=tolower(substr($10,1,2))
MONT=tolower(substr($10,3,2))
DAY=tolower(substr($10,5,2))
HOUR=tolower(substr($10,7,2))
MIN=tolower(substr($10,9,2))
SEC=tolower(substr($10,11,2))
LEN=tolower(substr($11,1,2))
ALEN=tolower(substr($6,1,2))
AN=tolower(substr($7,1,15))
slen = length(newnum)
slen1 = length(MONT)
slen2 = length(DAY)
slen3 = length(HOUR)
slen4 = length(MIN)
slen5 = length(SEC)
slen6 = length(YEAR)
slen7 = length(OPE)
# Here is where I get stuck
once next line is read, define
OPE=tolower(substr($2,21,2) substr($2,19,2))
slen7 = length(OPE)
decnum7 = 0
for (i=1;i<slen7+1;i++)
{
tposOP = index(hexstr,substr(OPE,i,1))-1
decnum7=decnum7+((16**(slen7 -i))*tposOP)
}
}
printf ("%11s %.2d-%.2d-%.2d %.2d:%.2d:%.2d %18s %10d (%d)\n",AN,decnum6,decnum5,decn
um1,decnum2,decnum3,decnum4,BN,decnum,decnum7)
}}}'
A sample of the record is
DSB=fb 00 80 00 01 0a 021941930000 0000 2a00 040907111d1c 0a 015306200000000000
+++= 00000010002c000000ca1f000102ac026000ad0416001500064a474448414298
+++= 020b
+++= 5050524841426400aa03041023ab08454e5155495232201702fc09ca1f00000000000000bc7f1e4f481f00000017bb40f530000052d2bb40f530433e0dda
Many Thanks
Chris
On my prevoius post I tried to align 3 lines into one, (thanks to PHV) some success. What I am now trying to achive is to , once /DSB/ is found , define what I need from that line ,and then read the next line which starts with +++=, and define $2 then once all defining is done use the printf statement.
My Script
/tools/Chris filename |
awk '{
Here is no problem ---- > if(match($1,"BIL=")){
for (e=1;e<NF;e++){if ($e~/^BIL/){
LA=$(e+4)
{if ($(e+4)==00){
Anum="NULL"
}else{
A_num=$(e+5)
}}}
if($e~/P=65/){
BNUM=$(e+2)
LN=$(e+1)
}
if($e~/P=64/){
DATE=$(e+1)
DUR=$(e+3)
}
if($e~/P=67/){
UN=$(e+1)
}}
hexstr="0123456789abcdef"
newnum=tolower(substr(DUR,5,2) substr(DUR,3,2) substr(DUR,1,2))
YEAR=tolower(substr(DATE,1,2))
MONT=tolower(substr(DATE,3,2))
DAY=tolower(substr(DATE,5,2))
HOUR=tolower(substr(DATE,7,2))
MIN=tolower(substr(DATE,9,2))
SEC=tolower(substr(DATE,11,2))
OPE=tolower(substr(UN,5,2) substr(UN,3,2) substr(UN,1,2))
LEN=tolower(substr(LN,1,2))
ALEN=tolower(substr(LA,1,2))
AN=tolower(substr(Anum,1,15))
decnum12 = 0
slen_bn = length(LEN)
#do some stuff here ---------->
}
printf ("%11s %.2d-%.2d-%.2d %.2d:%.2d:%.2d %18s %10d (%d)\n",AN,decnum6,decnum5,decn
um1,decnum2,decnum3,decnum4,BN,decnum,decnum7)
}
}
}else{
Here is no problem ---- > if(match($1,"DSB=")){
hexstr="0123456789abcdef"
newnum=tolower(substr($9,3,2) substr($9,1,2))
YEAR=tolower(substr($10,1,2))
MONT=tolower(substr($10,3,2))
DAY=tolower(substr($10,5,2))
HOUR=tolower(substr($10,7,2))
MIN=tolower(substr($10,9,2))
SEC=tolower(substr($10,11,2))
LEN=tolower(substr($11,1,2))
ALEN=tolower(substr($6,1,2))
AN=tolower(substr($7,1,15))
slen = length(newnum)
slen1 = length(MONT)
slen2 = length(DAY)
slen3 = length(HOUR)
slen4 = length(MIN)
slen5 = length(SEC)
slen6 = length(YEAR)
slen7 = length(OPE)
# Here is where I get stuck
once next line is read, define
OPE=tolower(substr($2,21,2) substr($2,19,2))
slen7 = length(OPE)
decnum7 = 0
for (i=1;i<slen7+1;i++)
{
tposOP = index(hexstr,substr(OPE,i,1))-1
decnum7=decnum7+((16**(slen7 -i))*tposOP)
}
}
printf ("%11s %.2d-%.2d-%.2d %.2d:%.2d:%.2d %18s %10d (%d)\n",AN,decnum6,decnum5,decn
um1,decnum2,decnum3,decnum4,BN,decnum,decnum7)
}}}'
A sample of the record is
DSB=fb 00 80 00 01 0a 021941930000 0000 2a00 040907111d1c 0a 015306200000000000
+++= 00000010002c000000ca1f000102ac026000ad0416001500064a474448414298
+++= 020b
+++= 5050524841426400aa03041023ab08454e5155495232201702fc09ca1f00000000000000bc7f1e4f481f00000017bb40f530000052d2bb40f530433e0dda
Many Thanks
Chris