need advice on AWK


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting need advice on AWK
# 8  
Old 04-17-2008
OK,
could you give an example of the output that you want?
# 9  
Old 04-17-2008
hallo

<b>I would like my output to be similar to the one below:</b>

LOGIN_ID ACTION_CODE DATE CASE_REFERENCE FRAUD_TYPE_ID ESTIMATE_LOSS
james_j Assign 19/03/2008 832090883 PD Summary alarm 29401.46
james_j Open 19/03/2008 838521885 High Aggregate Cost of Calls 112457.79
james_j Open 01/04/2008 838521885 High Aggregate Cost of Calls 112457.79
james_j Assign 07/04/2008 782078038 Very Long Duration Call 0.19
james_j Assign 07/04/2008 734646922 Very Long Duration Call 4
james_j Assign 07/04/2008 730799413 Very Long Duration Call 50.13
james_j Assign 07/04/2008 833063410 Very Long Duration Call 4261.97
james_j Open 07/04/2008 832090883 PD Summary alarm 29401.46
james_j Open 07/04/2008 838521885 High Aggregate Cost of Calls 112457.79
james_j Open 08/04/2008 782078038 Very Long Duration Call 0.19
james_j Open 08/04/2008 734646922 Very Long Duration Call 4
james_j Open 08/04/2008 832090883 PD Summary alarm 29401.46
james_j Open 08/04/2008 838521885 High Aggregate Cost of Calls 112457.79
james_j Open 09/04/2008 734646922 Very Long Duration Call 4
james_j Open 09/04/2008 730799413 Very Long Duration Call 50.13
james_j Open 09/04/2008 833063410 Very Long Duration Call 4261.97
james_j Open 09/04/2008 832090883 PD Summary alarm 29401.46
james_j Open 09/04/2008 838521885 High Aggregate Cost of Calls 112457.79
james_j Open 10/04/2008 782078038 Very Long Duration Call 0.19
james_j Open 10/04/2008 734646922 Very Long Duration Call 4
james_j Open 10/04/2008 730799413 Very Long Duration Call 50.13
james_j Open 10/04/2008 833063410 Very Long Duration Call 4261.97
james_j Open 11/04/2008 734646922 Very Long Duration Call 4
james_j Open 11/04/2008 832090883 PD Summary alarm 29401.46
james_j Open 17/04/2008 824115119 PD Summary alarm 118856.9
james_j Closed 17/04/2008 824115118 PD Summary alarm 118856.9

Total Loss for Open Tickets 807392.27
Total Loss for Closed Tickets 118856.9
Total Loss for Assigned Tickets 33717.75
# 10  
Old 04-17-2008
OK,
reading your post it's not clear if one row = one line.
Try to attach a sample from your data (or use code tags).

If the above is not true, you should change the sql (if the client is sqlplus: adjust the colum format and the linesize).
# 11  
Old 04-21-2008
Hi Radoulov,

I have decided to calculate the sum of the total_estimate_loss using sql.

Thnx for all your help.

Ta,Smilie
# 12  
Old 04-21-2008
This should give the expected output:

Code:
awk ' NR>1{arr[$2]+=$NF}
END{for(i in arr){printf("Total lost for %s Tickets %10.2f\n", i, arr[i])}}' file

# 13  
Old 04-21-2008
cat awkadvice.d | awk 'BEGIN {
Assign=0;
Open=1;
Closed=2;
sum[Assign]=0;
sum[Open]=0;
sum[Closed]=0;
}

{
print $0
if ($2 == "Assign" ) sum[Assign]=sum[Assign]+$NF;
if ($2 == "Open" ) sum[Open]=sum[Open]+$NF;
if ($2 == "Closed" ) sum[Closed]=sum[Closed]+$NF;
}

END {
print
print "Total estimated cost for Assign is " sum[Assign]
print "Total estimated cost for Open is " sum[Open]
print "Total estimated cost for Closed is " sum[Closed]

}'
# 14  
Old 04-21-2008
aju_cup,

The OP decided to use sqlplus to do the job, but have you tried to get the desired output with your script?
I don't!?

Regards
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
Login or Register to Ask a Question