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
posix_madvise(3C)					   Standard C Library Functions 					 posix_madvise(3C)

NAME
posix_madvise - memory advisory information SYNOPSIS
#include <sys/mman.h> int posix_madvise(void *addr, size_t len, int advice); DESCRIPTION
The posix_madvise() function advises the system on the expected behavior of the application with respect to the data in the memory starting at address addr, and continuing for len bytes. The system may use this information to optimize handling of the specified data. The posix_madvise() function has no effect on the semantics of access to memory in the specified range, although it may affect the performance of access. The advice to be applied to the memory range is specified by the advice parameter and may be one of the following values: POSIX_MADV_NORMAL Specifies that the application has no advice to give on its behavior with respect to the specified range. It is the default characteristic if no advice is given for a range of memory. POSIX_MADV_SEQUENTIAL Specifies that the application expects to access the specified range sequentially from lower addresses to higher addresses. POSIX_MADV_RANDOM Specifies that the application expects to access the specified range in a random order. POSIX_MADV_WILLNEED Specifies that the application expects to access the specified range in the near future. POSIX_MADV_DONTNEED Specifies that the application expects that it will not access the specified range in the near future. These values are defined in <sys/mman.h> RETURN VALUES
Upon successful completion, posix_madvise() returns zero. Otherwise, an error number is returned to indicate the error. ERRORS
The posix_madvise() function will fail if: EINVAL The value of advice is invalid. ENOMEM Addresses in the range starting at addr and continuing for len bytes are partly or completely outside the range allowed for the address space of the calling process. The posix_madvise() function may fail if: EINVAL The value of len is zero. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Committed | +-----------------------------+-----------------------------+ |MT-Level |MT-Safe | +-----------------------------+-----------------------------+ |Standard |See standards(5). | +-----------------------------+-----------------------------+ SEE ALSO
mmap(2), madvise(3C), posix_madvise(3C), attributes(5), standards(5) SunOS 5.11 14 Jul 2008 posix_madvise(3C)