need advice on AWK


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting need advice on AWK
# 15  
Old 04-22-2008
Code:
awk '{
arr[$2]=sprintf("%s\n%s",arr[$2],$0)
sum[$2]=sum[$2]+$NF
}
END{
for(i in arr)
{
	print arr[i]
	print "total -->" sum[i]
}
}' filename

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
Aspect::Advice::Around(3pm)				User Contributed Perl Documentation			       Aspect::Advice::Around(3pm)

NAME
Aspect::Advice::Around - Execute code both before and after a function SYNOPSIS
use Aspect; around { # Trace all calls to your module print STDERR "Called my function " . $_->sub_name . " "; # Lexically alter a global for this function local $MyModule::MAXSIZE = 1000; # Continue and execute the function $_->run_original; # Suppress exceptions for the call $_->return_value(1) if $_->exception; } call qr/^ MyModule::w+ $/; DESCRIPTION
The "around" advice type is used to execute code on either side of a function, allowing deep and precise control of how the function will be called when none of the other advice types are good enough. Using "around" advice is also critical if you want to lexically alter the environment in which the call will be made (as in the example above where a global variable is temporarily changed). This advice type is also the most computationally expensive to run, so if your problem can be solved with the use of a different advice type, particularly "before", you should use that instead. Please note that unlike the other advice types, your code in "around" is required to trigger the execution of the target function yourself with the "proceed" method. If you do not "proceed" and also do not set either a "return_value" or "exception", the function call will return "undef" in scalar context or the null list "()" in list context. AUTHORS
Adam Kennedy <adamk@cpan.org> COPYRIGHT AND LICENSE
Copyright 2010 Adam Kennedy. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2012-02-01 Aspect::Advice::Around(3pm)