Sponsored Content
Top Forums Shell Programming and Scripting How to calculate a sum of certain records? Post 74518 by vino on Friday 10th of June 2005 10:32:01 AM
Old 06-10-2005
I think for uniq to work properly, it needs a sort'ed list.

Not sure, tho'.

Vino
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Column sum group by uniq records

Dear All, I want to get help for below case. I have a file like this. saman 1 gihan 2 saman 4 ravi 1 ravi 2 so i want to get the result, saman 5 gihan 2 ravi 3 like this. Pls help me. (17 Replies)
Discussion started by: Nayanajith
17 Replies

2. Shell Programming and Scripting

Calculate total sum from a file

The file content is dynamic and using this format: name1 number1 name2 number2 name3 number3 name4 number4 .................... Need a smooth way to calculate the sum of all the numbers in that file (number1 + number2 + number3 + number4........ = total ) (11 Replies)
Discussion started by: TehOne
11 Replies

3. Shell Programming and Scripting

awk-calculate records of a text

I want to make a bash shell script that accepts as argument a file name (cars.txt) and: 1) calculates the total price per year and per model. 2) For each car that it's number starts with TK, I want to print the surname and name of the owner and the total cost for them. NBE3452... (3 Replies)
Discussion started by: Mark_orig
3 Replies

4. Solaris

calculate sum size of files by date (arg list too long)

Hi, I wanted a script to find sum of files for a particular date, below is my script ls -lrt *.req | nawk '$6 == "Aug"' | nawk '$7 == "1"'| awk '{sum = sum + $5} END {print sum}' However, i get the error below /usr/bin/ls: arg list too long How do i fix that. Many thanks before. (2 Replies)
Discussion started by: beginningDBA
2 Replies

5. Shell Programming and Scripting

Calculate age of a file | calculate time difference

Hello, I'm trying to create a shell script (#!/bin/sh) which should tell me the age of a file in minutes... I have a process, which delivers me all 15 minutes a new file and I want to have a monitoring script, which sends me an email, if the present file is older than 20 minutes. To do... (10 Replies)
Discussion started by: worm
10 Replies

6. Shell Programming and Scripting

Help with calculate total sum of same data problem

Long list of input file: AGDRE1 0.1005449050 AGDRE1 2.1005443435 AGDRE1 1.2005449050 AGDRE1 5.1005487870 AASFV3 50.456304789 AASFV3 2.3659706549 AASFV3 6.3489807860 AASFV3 3.0089890148 RTRTRS 5.6546403546 . . Desired output file: AGDRE1 8.5021829410 AASFV3 62.180245240... (2 Replies)
Discussion started by: perl_beginner
2 Replies

7. Homework & Coursework Questions

Calculate sum of the field

Hi All, I need to calculat the sum of the particular field in text file. And the datatype of the field in file is decimal(18,2). If the file is small, then I am facing any problem. But the file is huge, then the result is converted into exponential format. I tried using various command thr... (0 Replies)
Discussion started by: lathanandhini
0 Replies

8. Shell Programming and Scripting

Sum and calculate number in table

Hello everyone, I have some problem in calculation number using awk. input file format : S1 1 : 0.003 0.031 S2 1 : 0.020 0.095 S3 4 : 0.088 0.012 S4 2 : 0.010 0.090 S5 2 : 0.244 0.066 S6 3 : 0.249 0.751 S7 3 : 0.010 0.990 S8 3 : 0.230... (4 Replies)
Discussion started by: awil
4 Replies

9. Shell Programming and Scripting

Help with calculate the total sum of record in column one

Input file: 101M 10M10D20M1I70M 10M10D39M4I48M 10M10D91M 10M10I13M2I7M1I58M 10M10I15M1D66M Output file: 101M 101 0 0 10M10D20M1I70M 100 1 10 10M10D39M4I48M 97 4 10 10M10D91M 101 0 10 10M10I13M2I7M1I58M 88 13 0 10M10I15M1D66M 91 10 1 I'm interested to count how many total of... (6 Replies)
Discussion started by: perl_beginner
6 Replies

10. Shell Programming and Scripting

awk to calculate difference of split and sum the difference

In the awk I am trying to subtract the difference $3-$2 of each matching $4 before the first _ (underscore) and print that value in $13. I think the awk will do that, but added comments. What I am not sure off is how to add a line or lines that will add sum each matching $13 value and put it in... (2 Replies)
Discussion started by: cmccabe
2 Replies
RFIO_PRESEEK(3) 					      Rfio Library Functions						   RFIO_PRESEEK(3)

NAME
rfio_preseek - prefetch chunks of data from a file SYNOPSIS
#include <sys/types.h> #include "rfio_api.h" int rfio_preseek (int s, const struct iovec *iov, int iovnb); Under Linux, for large files: #define _LARGEFILE64_SOURCE #include <sys/types.h> #include "rfio_api.h" int rfio_preseek64 (int s, const struct iovec64 *iov, int iovnb); For large files, under other systems: #include <sys/types.h> #include "rfio_api.h" int rfio_preseek64 (int s, const struct iovec64 *iov, int iovnb); DESCRIPTION
rfio_preseek prefetches chunks of data at given offsets into an internal buffer (on the client side), using the descriptor s generated by a previous rfio_open. The actual offset values and the lengths are given in the array of structures iov. The number of chunks is specified by iovnb. rfio_preseek64 does the prefetch for large files, using an array of structures of type iovec64 rather than an array of iovec. RFIO_READOPT must be set to RFIO_READBUF, which is the default. The default internal buffer size is 128 kB, but the buffer size can be set with an entry RFIO IOBUFSIZE in shift.conf. Then rfio_read gets the data from that buffer. EXAMPLES
/* tpreseek - write NBRECORDS_TOWRITE records and read back NBRECORDS_TOREAD using the rfio_preseek function */ #include <fcntl.h> #include <stdio.h> #if defined(_WIN32) #include <winsock2.h> #endif #include "rfio_api.h" #define NBRECORDS_TOREAD 5 #define NBRECORDS_TOWRITE 10 main(argc, argv) int argc; char **argv; { char buf[65536]; int errflg = 0; int fd; int i; struct iovec iov[NBRECORDS_TOREAD]; int iovnb = NBRECORDS_TOREAD; int j; static int lengths[NBRECORDS_TOWRITE] = {4096, 32768, 16384, 8192, 65536, 32768, 16384, 4096, 65536, 8192}; static int records_toread[NBRECORDS_TOREAD] = {2, 4, 5, 8, 9}; #if defined(_WIN32) WSADATA wsadata; #endif if (argc != 2) { fprintf (stderr, "usage: tpreseek pathname "); exit (1); } #if defined(_WIN32) if (WSAStartup (MAKEWORD (2, 0), &wsadata)) { fprintf (stderr, "WSAStartup unsuccessful "); exit (2); } #endif while (! errflg) { /* Write variable length records. * Each record is filled with the record index */ if ((fd = rfio_open (argv[1], O_WRONLY|O_CREAT|O_TRUNC, 0644)) < 0) { rfio_perror ("rfio_open"); errflg++; break; } for (j = 0; j < NBRECORDS_TOWRITE; j++) { for (i = 0; i < lengths[j]; i++) buf[i] = j; if (rfio_write (fd, buf, lengths[j]) < 0) { rfio_perror ("rfio_write"); errflg++; break; } } (void)rfio_close (fd); if (errflg) break; /* Prefetch a few records: the actual offsets and lengths * of the records is set in the array of iov structures */ if ((fd = rfio_open (argv[1], O_RDONLY)) < 0) { rfio_perror ("rfio_open"); errflg++; break; } for (j = 0; j < NBRECORDS_TOREAD; j++) { /* compute record offset */ iov[j].iov_base = 0; for (i = 0; i < records_toread[j]; i++) iov[j].iov_base = (char *) iov[j].iov_base + lengths[i]; /* set length */ iov[j].iov_len = lengths[records_toread[j]]; } if (rfio_preseek (fd, iov, iovnb) < 0) { rfio_perror ("rfio_preseek"); errflg++; break; } /* Read back the records and check their cpntents */ for (j = 0; j < NBRECORDS_TOREAD; j++) { if (rfio_lseek (fd, (off_t) iov[j].iov_base, SEEK_SET) < 0) { rfio_perror ("rfio_lseek"); errflg++; break; } if (rfio_read (fd, buf, iov[j].iov_len) < 0) { rfio_perror ("rfio_read"); errflg++; break; } for (i = 0; i < iov[j].iov_len; i++) { if (buf[i] != records_toread[j]) { fprintf (stderr, "incorrect data read, record %d ", records_toread[j]); errflg++; break; } } if (errflg) break; } (void) rfio_close (fd); break; } if (rfio_unlink (argv[1]) < 0) { rfio_perror ("rfio_unlink"); errflg++; } #if defined(_WIN32) WSACleanup(); #endif exit (errflg ? 1 : 0); } RETURN VALUE
This routine returns 0 if the operation was successful or -1 if the operation failed. In the latter case, serrno is set appropriately. ERRORS
EBADF s is not a valid descriptor. EINVAL RFIO_READOPT is not set to RFIO_READBUF. SENOSHOST Host unknown. SENOSSERV Service unknown. SETIMEDOUT Timed out. SEBADVERSION Version ID mismatch. SECONNDROP Connection closed by remote end. SECOMERR Communication error. SENORCODE Host did not return error number. SEE ALSO
rfio_lseek(3), rfio_open(3), rfio_read(3) AUTHOR
LCG Grid Deployment Team LCG
$Date: 2005/03/31 13:13:03 $ RFIO_PRESEEK(3)
All times are GMT -4. The time now is 05:21 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy