Sponsored Content
Full Discussion: need advice on AWK
Top Forums Shell Programming and Scripting need advice on AWK Post 302186457 by kekanap on Thursday 17th of April 2008 09:40:34 AM
Old 04-17-2008
help

Hi,

Your awk script doesnt give me exactly what I want. Have a look below:

$ cat cm_activities_170408:0302.log
############################ ANALYST REPORT ####################################

LOGIN_ID ACTION_CODE DATE
---------------- ------------------------------ ---------
CASE_REFERENCE FRAUD_TYPE_ID ESTIMATE_LOSS
---------------------------------------------------------------- ------------------------------ -------------
james_j Assign 17-MAR-08
0838521885 High Aggregate Cost of Calls 112457.79

james_j Assign 17-MAR-08
0838117486 High Aggregate Cost of Calls 150801.75

james_j Assign 17-MAR-08
0833003470 High Frequency 77513.92

hyman_c Open 19-MAR-08
0838521885 High Aggregate Cost of Calls 112457.79

hyman_c Open 19-MAR-08
0838521885 High Aggregate Cost of Calls 112457.79

hyman_c Assign 19-MAR-08
0832090883 PD Summary alarm 29401.46

hyman_c Open 01-APR-08
0838521885 High Aggregate Cost of Calls 112457.79

hyman_c Open 07-APR-08
0838521885 High Aggregate Cost of Calls 112457.79

hyman_c Assign 07-APR-08
0734646922 Very Long Duration Call 4

hyman_c Assign 07-APR-08
0833063410 Very Long Duration Call 4261.97

hyman_c Assign 07-APR-08
0782078038 Very Long Duration Call .19

hyman_c Assign 07-APR-08
0730799413 Very Long Duration Call 50.13

hyman_c Open 07-APR-08
0832090883 PD Summary alarm 29401.46

hyman_c Open 07-APR-08
0832090883 PD Summary alarm 29401.46

hyman_c Open 08-APR-08
0734646922 Very Long Duration Call 4

hyman_c Open 08-APR-08
0782078038 Very Long Duration Call .19

hyman_c Open 08-APR-08
0734646922 Very Long Duration Call 4

hyman_c Open 08-APR-08
0782078038 Very Long Duration Call .19

hyman_c Open 08-APR-08
0838521885 High Aggregate Cost of Calls 112457.79

hyman_c Open 08-APR-08
0832090883 PD Summary alarm 29401.46

hyman_c Open 08-APR-08
0782078038 Very Long Duration Call .19

hyman_c Open 09-APR-08
0833063410 Very Long Duration Call 4261.97

hyman_c Open 09-APR-08
0832090883 PD Summary alarm 29401.46

hyman_c Open 09-APR-08
0832090883 PD Summary alarm 29401.46

hyman_c Open 09-APR-08
0734646922 Very Long Duration Call 4

hyman_c Open 09-APR-08
0730799413 Very Long Duration Call 50.13

hyman_c Open 09-APR-08
0838521885 High Aggregate Cost of Calls 112457.79

hyman_c Open 10-APR-08
0833063410 Very Long Duration Call 4261.97

hyman_c Open 10-APR-08
0782078038 Very Long Duration Call .19

hyman_c Open 10-APR-08
0782078038 Very Long Duration Call .19

hyman_c Open 10-APR-08
0734646922 Very Long Duration Call 4

hyman_c Open 10-APR-08
0734646922 Very Long Duration Call 4

hyman_c Open 10-APR-08
0833063410 Very Long Duration Call 4261.97

hyman_c Open 10-APR-08
0730799413 Very Long Duration Call 50.13

hyman_c Open 10-APR-08
0730799413 Very Long Duration Call 50.13

hyman_c Open 11-APR-08
0832090883 PD Summary alarm 29401.46

hyman_c Open 11-APR-08
0734646922 Very Long Duration Call 4

nhlaph_pr Assign 15-APR-08
0832124374 PD Summary alarm 72957.64

$
$ cat test_123.ksh
#!/bin/ksh
set -x
#########################################################################
#
awk 'END { for (k in x)
printf "ACTION_CODE: %s\n\n%s\n\nTotal: %60.2f\n\n",
k, x[k], sum[k] }
NR > 1 { s = $2; $2 = ""
x[s] = x[s] ? x[s]RS$0 : $0; sum[s] += $NF }' /minotaur/Log/stats/cm_activities_170408:0302.log > xxx.log



$ cat xxx.log
ACTION_CODE:


Total: 0.00

ACTION_CODE: ------------------------------

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

Total: 0.00

ACTION_CODE: Assign

james_j 17-MAR-08
james_j 17-MAR-08
james_j 17-MAR-08
hyman_c 19-MAR-08
hyman_c 07-APR-08
hyman_c 07-APR-08
hyman_c 07-APR-08
hyman_c 07-APR-08
nhlaph_pr 15-APR-08

Total: 113.00

ACTION_CODE: FRAUD_TYPE_ID

CASE_REFERENCE ESTIMATE_LOSS

Total: 0.00

ACTION_CODE: High

0838521885 Aggregate Cost of Calls 112457.79
0838117486 Aggregate Cost of Calls 150801.75
0833003470 Frequency 77513.92
0838521885 Aggregate Cost of Calls 112457.79
0838521885 Aggregate Cost of Calls 112457.79
0838521885 Aggregate Cost of Calls 112457.79
0838521885 Aggregate Cost of Calls 112457.79
0838521885 Aggregate Cost of Calls 112457.79
0838521885 Aggregate Cost of Calls 112457.79

Total: 1015520.20

ACTION_CODE: Open

hyman_c 19-MAR-08
hyman_c 19-MAR-08
hyman_c 01-APR-08
hyman_c 07-APR-08
hyman_c 07-APR-08
hyman_c 07-APR-08
hyman_c 08-APR-08
hyman_c 08-APR-08
hyman_c 08-APR-08
hyman_c 08-APR-08
hyman_c 08-APR-08
hyman_c 08-APR-08
hyman_c 08-APR-08
hyman_c 09-APR-08
hyman_c 09-APR-08
hyman_c 09-APR-08
hyman_c 09-APR-08
hyman_c 09-APR-08
hyman_c 09-APR-08
hyman_c 10-APR-08
hyman_c 10-APR-08
hyman_c 10-APR-08
hyman_c 10-APR-08
hyman_c 10-APR-08
hyman_c 10-APR-08
hyman_c 10-APR-08
hyman_c 10-APR-08
hyman_c 11-APR-08
hyman_c 11-APR-08

Total: 272.00

ACTION_CODE: ACTION_CODE

LOGIN_ID DATE

Total: 0.00

ACTION_CODE: Very

0734646922 Long Duration Call 4
0833063410 Long Duration Call 4261.97
0782078038 Long Duration Call .19
0730799413 Long Duration Call 50.13
0734646922 Long Duration Call 4
0782078038 Long Duration Call .19
0734646922 Long Duration Call 4
0782078038 Long Duration Call .19
0782078038 Long Duration Call .19
0833063410 Long Duration Call 4261.97
0734646922 Long Duration Call 4
0730799413 Long Duration Call 50.13
0833063410 Long Duration Call 4261.97
0782078038 Long Duration Call .19
0782078038 Long Duration Call .19
0734646922 Long Duration Call 4
0734646922 Long Duration Call 4
0833063410 Long Duration Call 4261.97
0730799413 Long Duration Call 50.13
0730799413 Long Duration Call 50.13
0734646922 Long Duration Call 4

Total: 17277.54

ACTION_CODE: PD

0832090883 Summary alarm 29401.46
0832090883 Summary alarm 29401.46
0832090883 Summary alarm 29401.46
0832090883 Summary alarm 29401.46
0832090883 Summary alarm 29401.46
0832090883 Summary alarm 29401.46
0832090883 Summary alarm 29401.46
0832124374 Summary alarm 72957.64

Total: 278767.86

$
 

10 More Discussions You Might Find Interesting

1. UNIX Desktop Questions & Answers

Looking for some advice

I am looking for some advice on wether to use unix or red hat linux? I have played with most windows OS and Mac OS up to in and including OS X. any and all advice would be appreciated (4 Replies)
Discussion started by: justawind
4 Replies

2. UNIX for Dummies Questions & Answers

Need advice: Awk vs something else?

I have a while read loop cycling through a fixed-length csv file and I'd like to use an if statement to check two fields in each line. I'm basically asking for your suggestions on the best and easiest way to check two fields in each line. I'm sure many of you may be thinking just use awk, but if... (1 Reply)
Discussion started by: yongho
1 Replies

3. Shell Programming and Scripting

first script. need help and advice.

Hello everyone, This is my first post here and this is the first time I am using UNIX OS (Slackware). I find it really useful and powerful and would like to master it but as you may guess I am expreicing quite a few problems. I've been reading a few documentations about it and bash this week... (17 Replies)
Discussion started by: sanchopansa
17 Replies

4. Shell Programming and Scripting

looking for advice...

Hi. First of all, Im an msoft guy, and when it comes to linux/unix, I'm retarded. Here is what I'm trying to do. I want to start I want to automatically connect to a remote server. Then I need it to login(https) -insert the licensce in the box(vi) -based on that licensce, the... (1 Reply)
Discussion started by: bravo24601
1 Replies

5. UNIX for Dummies Questions & Answers

need advice

i am currently running windows vista home premium, i want to install unix because i just started a computer programing course, i am just wondering if i install unix will i still have vista?? how does it work? will i get a choice of which os to run on system startup?? (1 Reply)
Discussion started by: naner9
1 Replies

6. Red Hat

Any advice would help

Hi everyone. I must admit up front that I am not very strong when it comes to Linux. I am actually a Windows guy, but don't let that count against me. :) I work for a very small company so we do not have a Server/Linux Admin on staff. Most of our needs have been handled by our WebHost. We have... (2 Replies)
Discussion started by: liquidstyleb
2 Replies

7. Shell Programming and Scripting

AWK\SED advice

Hi guys, looking for a little bit of help. I have been given a task to sift through this massive config of events. I need to find out which event is set up for which ID and each entry looks a little like; <test1 CONNECT_TYPE = COPY HOST = USER = PASSWORD =... (1 Reply)
Discussion started by: JayC89
1 Replies

8. AIX

Need career advice please

Hi all, I'm a Solaris/linux sysadmin with a good general UNIX skills and with a little tiny background on AIX with no exposure to IBM's hardware ( just reading ) , but i think i can cope with it . UNIX jobs nowadays are rare here ( i mean hp-ux , solaris , aix ) not linux specially after the... (6 Replies)
Discussion started by: h@foorsa.biz
6 Replies

9. Shell Programming and Scripting

Advice on using awk in ksh with system date

OK I have a simple awk script: $ awk '/03\/11\/10/' foofile|awk -f finderrors.awk I want to use in the ksh script to so that I can do something like this: #!/bin/ksh TODAY=`date +"%D"` awk /$TODAY/ foofile|awk -f finderrors.awk The problem I am having is (I believe) is with the special... (3 Replies)
Discussion started by: bike4life
3 Replies

10. Shell Programming and Scripting

Need Advice

Guys, Can you tell me what value would additional knowledge of PERL and CGI scripting will add to my skill set of UNIX shell scripting and ORACLE PL/SQL? I understand that PERL is a good tool for text processing. (1 Reply)
Discussion started by: yabhi_22
1 Replies
All times are GMT -4. The time now is 08:27 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy