============================================================================================================================================================================================================= ===========
1. Use the AWK to make statistics according to the telephone number
============================================================================================================================================================================================================= ===========
Under normal circumstances, the telephone company will generate a pennail file from the switch, the file name also has a certain format. If the author is going to address, the single format is as follows: [ZENGZC @ zcbill bill_data] $ cat ticket_20041210_118781141, 10, 10, 120, 0 , 2004121009292087881142,10,30,230, -10,2004121009292087881143,10,30,100, -20,2004121009292087881143,10,30,110, 10,2004121009382587881143,10,40, 90, 0,2004121009500587881146,10,15, 45, 0,2004121009252587881130,10 , 15, 80, 0,2004121009252587881131,10,45, 60, 0,2004121009030687881132,10,45,300, 20,2004121010010187881133,10,60, 45, 20,2004121010010187881134,10,10, 55, -10,2004121010101087881134,10, 20, 55, -10, 20081143, 10, 20, 60, 0, 20043, 10, 10, 20, 0, 20041210, 10, 20, 0, 200412, 10, 10, 20, 200412, 10, 10, 0, 200412, 10, 10, 20, 200412, 10, 10, 20, 200412, 10, 10, 20, 200412, 10, 10,, are the substantial fee No. 13-14 is the long distance fee 16 ~ 18 is additional fees 20-22 for the date of the preferential fees 24 to 27 for YYYYMMDDHH24MISS format. If I want to summarize the basic fee of each customer long distance fee surcharge preferential fee, then the total amount of consumption is available. Of course, if it is very easy to use Oracle, first import the data into the Oracle database, and then make SUM in the phone number in the phone number OK. Of course, I would like to use AX or GAWK (under Linux, GNU) under AIX, and then import into the Oracle database. I have tried, in general, a daily voice of a local network is a number of tens of thousands or billions of records, which is advantageous to use AWK on the processing speed. The following is a simple introduction.
1), first write the following AWK program: [ZENGZC @ zcbill bill_data] $ cat statfee.sh #! / Bin / gawk -fbegin / {fs = ","} {PhoneList [$ 1] = $ 1 alfeesperphone = $ 2 $ 3 $ 4 $ 5fee [$ 1] = allfeesperphone}; end / {for (row in phone) {print "Phone Number:" Phonelist [Row] "All Fees:" Fee [Row]}} 2), chmod x StatFee.sh3), execute: ./ StatFee.sh Ticket_20041210_114), get, draw the following data: Phone Number: 87881130 All Fees: 105Phone Number: 87881131 All Fees: 115Phone Number: 87881132 All Fees: 375Phone Number: 87881141 All Fees: 140Phone Number: 87881133 All Fees: 135Phone Number: 87881142 All Fees: 260Phone Number: 87881134 All Fees: 140Phone Number: 87881143 All Fees: 550Phone Number: 87881146 All Fees: 70 ============== =================================================
2. Use the AWK to realize the statistical method of statistical guns in accordance with the time period.
============================================================================================================================================================================================================= =========== 1) There is the following data (the same as the first part, just use AWK to separate the data first, the specific segmentation method is seen later): [zengzc @ zcbill bill_data ] $ cat Ticket_20041210_11_187881141,10,10,120, 0,20041210,09,292087881142,10,30,230, -10,20041210,09,292087881143,10,30,100, -20,20041210,09,292087881143,10,30,110, 10,20041210 , 09, 38258788143, 10, 40, 90, 0, 4888146, 10, 15, 45, 0, 0, 20041210, 109, 252587881130, 10, 25, 80, 0, 20041210, 09, 252587881131, 10, 45 , 60, 0,20041210,09,030,068,881132,10,45,300, 20,20041210, 10,010,018,88133, 10,60,0,018788,41210, 10,010,0,888,41210, 10,0,018788,41210, 10,0,018788,0412, 10, 10, 55, -10, 20041210, 10, 101087881134, 10, 20, 55, -10, 20041210, 10, 202087881143, 10, 20, 0, 0, 20041210, 11, 10, 0, 20041210, 11, 10, 0, 20041210, 11, 15152) Write a WK script, and Stored as: statfee_time.sh [zengzc @ zcbill bill_data] $ cat statfee_time.sh #! / Bin / awk -f begin / {fs = "} {Timelist [$ 7] = $ 7 allfeesperphone = $ 2 $ 3 $ 4 $ 5 FeE [$ 7] = allfeesperphone}; end / {for (row in time) print "Time Section:" Timelist [ROW] "All Fees:" Fee [ROW]} 3), make the script statfee_time.sh executable
CHMOD X statfee_time.sh4) Execute ./statfee_time.sh ticket_20041210_11_1, ok, result: