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

NAME
posix_fadvise - file advisory information SYNOPSIS
#include <fcntl.h> int posix_fadvise(int fd, off_t offset, off_t len, int advice); DESCRIPTION
The posix_fadvise() function advises the system on the expected behavior of the application with respect to the data in the file associated with the open file descriptor, fd, starting at offset and continuing for len bytes. The specified range need not currently exist in the file. If len is zero, all data following offset is specified. The system may use this information to optimize handling of the specified data. The posix_fadvise() function has no effect on the semantics of other operations on the specified data, although it may affect the performance of other operations. The advice to be applied to the data is specified by the advice parameter and may be one of the following values: POSIX_FADV_NORMAL Specifies that the application has no advice to give on its behavior with respect to the specified data. It is the default characteristic if no advice is given for an open file. POSIX_FADV_SEQUENTIAL Specifies that the application expects to access the specified data sequentially from lower offsets to higher off- sets. POSIX_FADV_RANDOM Specifies that the application expects to access the specified data in a random order. POSIX_FADV_WILLNEED Specifies that the application expects to access the specified data in the near future. POSIX_FADV_DONTNEED Specifies that the application expects that it will not access the specified data in the near future. POSIX_FADV_NOREUSE Specifies that the application expects to access the specified data once and then not reuse it thereafter. These values are defined in <fcntl.h> RETURN VALUES
Upon successful completion, posix_fadvise() returns zero. Otherwise, an error number is returned to indicate the error. ERRORS
The posix_fadvise() function will fail if: EBADF The fd argument is not a valid file descriptor. EINVAL The value of advice is invalid, or the value of len is less than zero. ESPIPE The fd argument is associated with a pipe or FIFO. USAGE
The posix_fadvise() function has a transitional interface for 64-bit file offsets. See lf64(5). 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
posix_madvise(3C), attributes(5), standards(5) SunOS 5.11 14 Jul 2008 posix_fadvise(3C)