Core iTOps Tube

Monday, 7 May 2012

awk get length of a binary file.

Hi..



Just got a problem with awk and cannot figure out whats the issue. I am not really expert in awk so looking for help/opinion from experts



Command is



$ cat abinaryfile | sed -e "s/@@//g;s/@$//" | awk ' begin {} { printf(length($0)); }'



Well its a binary file and I am looking to get a count of this file. If I use awk version 3.1.3 . it counts the whole binary file and give me desired result (9126) but we are roling out to RHEL6 and awk version in this is 3.1.7 and it seems there is some change in this version as now it counts only I suppose first column.(8)

--------------------------------------------

$ cat TT120T0-inbound | sed -e "s/@@//g;s/@$//" | awk ' begin {} { printf(length()); }'

8



(Awk 3.1.7)

------------------------------------------------------

$ cat TT120T0-inbound | sed -e "s/@@//g;s/@$//" | ./awk ' begin {} { printf(length()); }'

9126



( Awk 3.1.3)

----------------------------------------------------

I might be doing wrong so it anyone can tell me how to count the length of whole binary file..



Any help would be great.





Cheers

Sam



---------- Post updated at 11:42 AM ---------- Previous update was at 11:29 AM ----------



Binary File contains this data

------------------------------------------

J1644�697040010502500112050300000013606033010122001T00000001�1644�DŽ

165186007600090864000000120412063056C10101C5434C6036341701100000000279900000000000023953339221030000 0000007406013606069996740059622080002003MCC0003003MCC014801239204582840201490063920000158029MCC10401 01 12050303 NNNNN0165030M 01910012022800111000060Automatic response message for DE031 95333922103000000000074016 MCC 0419 00000002060136060699967406013606�1644�DŽ

165186007600090864000000120412063056C10101C5434C6036322701100000000279900000000000023953339221030000 0000019906013606069996740059622080002003MCC0003003MCC014801239204582840201490063920000158029MCC10401 01 12050303 NNNNN0165030M 01910012022800111000060Automatic response message for DE031 95333922103000000000199016 MCC 0419 00000003060136060699967406013606�1644�DŽ

165186007600090864000000120412063311C10101C5434C603630570110000000026200000000@@00000239533392210300 000000011606013606069996740059642080002003MCC0003003MCC014801282624582840201490068260000158029MCC104 0101 12050303 NNNNN0165030M 01910012022800111000060Automatic response message for DE031 95333922103000000000116016 MCC 0419 00000004060136060699967406013606�1644�DŽ

1651860076000908640000001204120631532209992592226036342701100000000379700000000000023953339221030000 00000066060136060699967400596Z2040002003MCC0003003MCC01480088402458201490068400000158029MCC1040101 12050303 NNNNN0165030M 01910012022800111000060Automatic response message for DE031 95333922103000000000066016 MCC 0419 00000005060136060699967406013606�1644�DŽ

1651860076000908640000001204120631532209992592226036322701100000000379700000000000023953339221030000 00000181060136060699967400596Z2040002003MCC0003003MCC01480088402458201490068400000158029MCC1040101 12050303 NNNNN0165030M 01910012@@022800111000060Automatic response message for DE031 95333922103000000000181016 MCC 0419 00000006060136060699967406013606�1442�DŽ!�16518600760009086400000000000000350400000001058663021118120 412063056C10101C5434C4504849701100000000279900000000000023953339221030000000001080601360606999674005 96263TRAVELEX MERCHANT\JALANTUN PERAK\MENARA MAYBAN\50050 KULMYS3440002003MCC0003003MCC0023003NA 0146036002901840000000000039458000000000118014801239204582840201490063920000158029MCC104010173120503 03 NNNNN01590672485 6870582456 1AP00000004M12050303120503010165030M 0177002YN01910012026200101000060Automatic response message for DE031 953339221030000000001088404580200058458D000000010000016 MCC 0419 00000007060136060699967410001606924306013606�1442�DŽ!�16518600760009086400000000000000425500000001285 463020916120412063311C10101C5434C4504807701100000000262000000000000023953339221030000000000250601360 60699967400596463TRAVELEX@@ MERCHANT\JALANTUN PERAK\MENARA MAYBAN\50050 KULMYS3440002003MCC0003003MCC0023003NA 0146036002901840000000000047458000000000142014801282624582840201490068260000158029MCC104010173120503 03 NNNNN01590672485 6870582456 1AP00000004M12050303120503010165030M 0177002YN01910012026200101000060Automatic response message for DE031 953339221030000000000258404580200058458D000000012000016 MCC 0419 00000008060136060699967410001606924506013606�1442�DŽ!�16518600760009086400000000000000425500000001285 463020916120412063311C10101C5434C4504849701100000000262000000000000023953339221030000000001400601360 60699967400596463TRAVELEX MERCHANT\JALANTUN PERAK\MENARA MAYBAN\50050 KULMYS3440002003MCC0003003MCC0023003NA 0146036002901840000000000047458000000000142014801282624582840201490068260000158029MCC104010173120503 03 NNNNN01590672485 6870582456 1AP00000004M12050303120503010165030M 0177002YN019@@10012026200101000060Automatic response message for DE031 953339221030000000001408404580200058458D000000012000016 MCC 0419 00000009060136060699967410001606924706013606�1442�DŽ!�16518600760009086400000000000000379700000001147 1630210691204120631532209992592224504808701100000000379700000000000023953339221030000000000900601360 60699967400596Z63TRAVELEX MERCHANT\JALANTUN PERAK\MENARA MAYBAN\50050 KULMYS3400002003MCC0003003MCC0023003NA 014603600290184000000000004245800000000012701480088402458201490068400000158029MCC10401017312050303 NNNNN01590672485 6870582456 1AP00000004M12050303120503010165030M 0177002YN01910012026200101000060Automatic response message for DE031 953339221030000000000908404580200058458D000000011000016 MCC 0419 00000010060136060699967410001606924906013606�1442�DŽ!�16518600760009086400000000000000175200000000529 363021118120412063056C10101C5434C45348077011000000002799000000000000239533392210300@@000000013206013 6060699967400596263TRAVELEX MERCHANT\JALANTUN PERAK\MENARA MAYBAN\50050 KULMYS3440002003MCC0003003MCC0023003NA 0146036002901840000000000019458000000000057014801239204582840201490063920000158029MCC104010173120503 03 NNNNN01590672485 6870582456 1AP00000004M12050303120503010165030M 0177002YN01910012026200101000060Automatic response message for DE031 953339221030000000001328404580200058458D000000010000016 MCC 0419 00000011060136060699967410001606924406013606�1442�DŽ!�16518600760009086400000000000000141800000000428 463021156120412063311C10101C5434C4534808701100000000262000000000000023953339221030000000000580601360 60699967400596463TRAVELEX MERCHANT\JALANTUN PERAK\MENARA MAYBAN\50050 KULMYS3440002003MCC0003003MCC0023003NA 0146036002901840000000000016458000000000048014801282624582840201490068260000158029MCC104010173120503 03 NNNNN01590672485 6870582456 1AP00000004M12050303120503010165030@@M 0177002YN01910012026200101000060Automatic response message for DE031 953339221030000000000588404580200058458D000000012000016 MCC 0419 00000012060136060699967410001606924606013606�1442�DŽ!�16518600760009086400000000000000212700000000642 663021156120412063311C10101C5434C4534849701100000000262000000000000023953339221030000000001730601360 60699967400596463TRAVELEX MERCHANT\JALANTUN PERAK\MENARA MAYBAN\50050 KULMYS3440002003MCC0003003MCC0023003NA 0146036002901840000000000023458000000000069014801282624582840201490068260000158029MCC104010173120503 03 NNNNN01590672485 6870582456 1AP00000004M12050303120503010165030M 0177002YN01910012026200101000060Automatic response message for DE031 953339221030000000001738404580200058458D000000012000016 MCC 0419 00000013060136060699967410001606924806013606�1442�DŽ!�16518600760009086400000000000000094900000000286 7630210741204120631532209992592224534@@8087011000000003797000000000000239533392210300000000012406013 6060699967400596Z63TRAVELEX MERCHANT\JALANTUN PERAK\MENARA MAYBAN\50050 KULMYS3400002003MCC0003003MCC0023003NA 014603600290184000000000001045800000000003001480088402458201490068400000158029MCC10401017312050303 NNNNN01590672485 6870582456 1AP00000004M12050303120503010165030M 0177002YN01910012026200101000060Automatic response message for DE031 953339221030000000001248404580200058458D000000011000016 MCC 0419 00000014060136060699967410001606925006013606�644��68068621660148004840203000250011205030000001360603 3010380017D00000000000220570381017C00000000000000000384017D00000000000220570400010000000000804010100 00000000004020100000000008840000000150601360606013606g1644��6856862302014800445820165001M03000250011 205030000001360603301037200714424500374002000378001O0390017D00000000000477650391017C0000000000000000 039201800D000000000000000039301800C00000000@@00005290394017D00000000000477650395016C0000000000005290 396017D000000000004723604000100000000004040101000000000000402010000000000445800000016060136060601360 6g1644��6856862302014800445820165001M03000250011205030000001360603301037200714424530374002000378001O 0390017D00000000000188700391017C0000000000000000039201800D000000000000000039301800C00000000000020403 94017D00000000000188700395016C0000000000002040396017D00000000000186660400010000000000404010100000000 00004020100000000004458000000170601360606013606h1644�69507001050250011205030000001360603301030101600 0000000002205703060080000001800000018@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@




No comments:

Post a Comment