Sponsored Content
Top Forums Shell Programming and Scripting awk summing specific lines and fields Post 302725235 by nakaedu on Friday 2nd of November 2012 12:59:22 AM
Old 11-02-2012
I have to apologize, my original post is not clear enough.
I have removed my original requirement to sum fields $13 and $14 because it is adding complexity and I don't really require them for the moment.
I will try to clarify my requirement,
I have a very long list nearly 1100 lines,
Each line is very similar to these

Code:
x;x;x;x;x;x;x;x;467,390,611 Bytes;0.435291 GB;0.062247 GB;0.373045 GB;11,225;157
a;a;a;a;a;a;a;a;13,805,156,846 Bytes;12.857054 GB;1.838559 GB;11.018495 GB;151,063;18,933
b;b;b;b;b;b;b;b;232,797,478,723 Bytes;216.809547 GB;31.003765 GB;185.805782 GB;176,861;21,445;Parent: Line #545

And I need to sum all fields to obtain: the total number of bytes, and GB. (while removing those lines that contain wording "Parent: Line"

For my example the total number of bytes and gigabytes, would be something similar to:
Code:
14272547457 Bytes;13.292345 GB;1.900806 GB;11.39154 GB

I get those numbers by summing all the row of fields $9, $10, $11, $12

467,390,611 Bytes + 13,805,156,846 Bytes = 14272547457 Bytes
0.435291 GB + 12.857054 GB = 13.292345 GB
0.062247 GB + 1.838559 GB = 1.900806 GB
0.373045 GB + 11.018495 GB = 11.39154 GB

Last edited by nakaedu; 11-02-2012 at 02:04 AM..
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

summing up the fields in fixed width file

Hi, I have a fixed width file with some records as given below: " 1000Nalsdjflj243324jljlj" "-0300Njfowjljl309933fsf" " 0010Njsfsjklj342344fsl" I want to sum-up first field values(i.e from 2nd character to 6th character)of each record. so for the above file i want to add (1000 - 300+... (2 Replies)
Discussion started by: srilaxmi
2 Replies

2. UNIX for Dummies Questions & Answers

Updating specific fields with awk using conditions

Can someone help me again, I think with awk? I have a file with 4 columns (pipe-delimited): I just want to convert the last field so that e1 is now 'message 1', e2 is 'message 2', e0 is 'message 3', etc. I don't want to change any other columns because the e0-e10 code may appear as part of a... (4 Replies)
Discussion started by: giannicello
4 Replies

3. Shell Programming and Scripting

Summing over specific lines and replacing the lines with the sum using sed, awk

Hi friends, This is sed & awk type question. I have a text file which has numbers spread all over the file. I want to sum the series of numbers whenever i find it and produce an output file with the sum. For example ###start of input text file #### abc def ghi 1 2 3 4 kjld random... (3 Replies)
Discussion started by: kaaliakahn
3 Replies

4. Shell Programming and Scripting

Summing over specific lines and replacing the lines with the sum

Hi friends, This is sed & awk type question. It is slightly different from my previous question. I have a text file which has numbers spread all over the file. I want to sum the series of numbers (but no more than 10 numbers in series) whenever i find it and produce an output file with the... (4 Replies)
Discussion started by: kaaliakahn
4 Replies

5. Shell Programming and Scripting

Summing all fields in a file

I was playing around to see how stuff works, and was trying to sum all fields in a file. cat file 1 2 3 4 5 6 7 8 9 10 11 12 I made this script: awk 'BEGIN {OFS=RS}{$1=$1}{s+=$0} END {print "sum="s}' file This gives 15, why not 78? I test it like this awk 'BEGIN... (5 Replies)
Discussion started by: Jotne
5 Replies

6. UNIX for Dummies Questions & Answers

Read the file and generate specific fields by awk

Hi I need to generate these output file from the below input file. Output : customer_id as customer, zip as zip_cd, catg_cd as catg, Input: out.customer::in.customer_id; out.zip_cd::in.zip; out.catg::in.catg_cd; Could you please help me on this. Please use code tags next... (1 Reply)
Discussion started by: Murugesh
1 Replies

7. Shell Programming and Scripting

Getting max value of specific fields with awk

Hello All, Here is am trying to get maximum value of third field depending on first,second and fourth fields with awk command . delimeter is pipe(|) . input 0221|09|14.25|aaa 0221|09|44.27|aaa 0221|09|44.33|aaa 0221|09|44.53|bbb 0221|09|34.32|bbb 0221|09|37.13|bbb... (5 Replies)
Discussion started by: sayami00
5 Replies

8. Shell Programming and Scripting

awk to combine lines if fields match in lines

In the awk below, what I am attempting to do is check each line in the tab-delimeted input, which has ~20 lines in it, for a keyword SVTYPE=Fusion. If the keyword is found I am splitting $3 using the . (dot) and reading the portion before and after the dot in an array a. If it does have that... (12 Replies)
Discussion started by: cmccabe
12 Replies

9. UNIX for Beginners Questions & Answers

Grep or awk a unique and specific word across many fields

Hi there, I have data with similar structure as this: CHR START-SNP END-SNP REF ALT PATIENT1 PATIENT2 PATIENT3 PATIENT4 chr1 69511 69511 A G homo hetero homo hetero chr2 69513 69513 T C . hetero homo hetero chr3 69814 69814 G C . . homo homo chr4 69815 69815 C A hetero . . hetero is... (10 Replies)
Discussion started by: daashti
10 Replies
NFSSTAT(1)						    BSD General Commands Manual 						NFSSTAT(1)

NAME
nfsstat -- display NFS statistics SYNOPSIS
nfsstat [-cseuv] [-w wait] [-n net|user] [-m [mountpath]] DESCRIPTION
nfsstat displays statistics kept about NFS client and server activity, active user activity, exported directories, and mount information. In the absence of any options, nfsstat displays NFS client and server statistics. The options are as follows: -c Show NFS client statistics. -e Show NFS server exported directory statistics. -m [mountpath] Show NFS mount information. -s Show NFS server statistics. -u Show NFS server active user statistics. -w wait Display a shorter summary at wait second intervals. -n net|user Show network addresses as numbers, or show users as uid numbers. This option can appear multiple times. -v Show additional information (if available). OUTPUT
The data fields that nfsstat displays for each set of statistics are: Client Information: Statistics for NFS file system mounts. RPC Counts Counts of the RPC calls made to each of the NFS protocol procedures. RPC Info Statistics for NFS RPC calls: TimedOut RPC calls that timed out, perhaps to a slow or dead server. Invalid Invalid RPC replies. X Replies RPC replies received that did not have calls pending. Retries RPC calls that were retried. Requests Total number of RPC calls made. Cache Info Statistics on NFS client-side cache performance: Attr Hits/Misses Performance of the NFS file attribute cache. Lkup Hits/Misses Performance of the directory name lookup cache. BioR Hits/Misses Performance of block cache for reads. BioW Hits/Misses Performance of block cache for writes. BioRL Hits/Misses Performance of symbolic link cache. BioD Hits/Misses Performance of directory cache. DirE Hits/Misses Performance of directory offset cache. Server Information: Statistics for the NFS server. RPC Counts Counts of RPC calls on each of the NFS server's procedures are recorded here. Server Ret-Failed RPC errors returned by the server. Server Faults Errors in the NFS server. Server Cache Stats Statistics from the NFS server's RPC duplicate request cache: Inprog Calls already in progress. Idem Cache hits for idempotent procedures. Non-idem Cache hits for non-idempotent procedures. Misses Cache Misses. Server Write Gathering These statistics describe the efficiency of the NFS server's write gathering feature. WriteOps Write operations to disk. WriteRPC Write operations received by the server. Opsaved Write operations that were gathered (WriteRPC - WriteOps) NFS Server Exported Directory Information: Statistics for each exported directory on the NFS server. NFS Requests Count of NFS requests processed by an exported directory. Bytes Read Count of bytes read from an exported directory. Bytes Written Count of bytes written to an exported directory. NFS Server Active User Information: List of active NFS users and statistics on the NFS server. NFS Requests Count of NFS requests received from an active user. Bytes Read Count of bytes read by an active user. Bytes Written Count of bytes written by an active user. Idle Amount of time an active user has been idle. User Name (or uid if -n user was given) of active user. IP Address Host name (or network address if -n net was given) of client machine. NFS Mount Information: Information about the given NFS mount (or all NFS mounts). The path mounted on and the server:/path that is mounted. Mount arguments originally passed in to the mount. Current mount parameter values and status information. SEE ALSO
netstat(1), iostat(8), mount_nfs(8), nfsd(8) HISTORY
The nfsstat command appears in 4.4BSD. 4.4BSD January 11, 2011 4.4BSD
All times are GMT -4. The time now is 05:06 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy