Sponsored Content
Top Forums Shell Programming and Scripting Totals in a file - incorrectly displaying Post 302480146 by mcclunyboy on Tuesday 14th of December 2010 08:28:55 AM
Old 12-14-2010
I am going to try and be a bit clearer. I use the following code to display the total of all fields in a column - $(awk '{s+=$3}END {print "T, "s}'. This prints "T, Total"

Sample file:

C, 818128, 5612.13122010,,,,
C, 818129, 1598.13122010,,,,
C, 818130, 7896.13122010,,,,
C, 818131, 2655.13122010,,,,
T, 1776

I am hoping it displays 17761...can anyone explain why it doesnt?

---------- Post updated at 08:28 AM ---------- Previous update was at 05:59 AM ----------

Got it sorted...

It was down to decimal points which I have been removing, for some reason when i removed the decimal point it removed the final digit.

Reorganisation and step by step breakdown solved this problem - many thanks
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Writing to a log file incorrectly

I have this script: #!/bin/ksh ######### Environment Setup ######### PATH=/gers/nurev/menu/pub/sbin:/gers/nurev/menu/pub/bin:/gers/nurev/menu/pub/mac :/gers/nurev/menu/adm/sbin:/gers/nurev/menu/adm/bin:/gers/nurev/menu/adm/mac:/ge... (5 Replies)
Discussion started by: heprox
5 Replies

2. Shell Programming and Scripting

Calculating totals in AWK

Hello, With the following small script I list the size of documents belonging to a certain user by each time selecting the bytes-field of that file ($7). Now it fills the array with every file it finds so in the end the output of some users contains up to 200.000 numbers. So how can I calculate... (7 Replies)
Discussion started by: Hille
7 Replies

3. Shell Programming and Scripting

summarising totals in awk

awk ' FILENAME == "all" { balance += substr($0,17,13) dt = substr($0,6,8) } END { for ( name in balance ) printf("%013s %3s of %8s\n", balance/100,name,dt) | "sort " } ' all > summation using this code i wanted to take summary totals of... (3 Replies)
Discussion started by: paresh n doshi
3 Replies

4. Shell Programming and Scripting

[Solved] Find Specific records from file and add totals into variables

Hi Eveyone, I am working on one shell script to find the specific records from data file and add the totals into variables and print them. you can find the sample data file below for more clarification. Sample Data File: PXSTYL00__20090803USA CHCART00__20090803IND... (7 Replies)
Discussion started by: veeru
7 Replies

5. Shell Programming and Scripting

Report Totals

Hello, I have written a script in a previous server and its being migrated to a new server. I'm trying to debug my script since i've had to make minor changes to it to get it to work. I'm having a hard time getting my totals to populate here is the syntax DUMP_COUNT=`sqlplus -S... (4 Replies)
Discussion started by: senormarquez
4 Replies

6. Shell Programming and Scripting

Trying to combine upload and download totals from txt file by ip address

I have two files, uploads.txt and downloads.txt. I would like to combine the columns of these files based on the ip address. How can I best do this? Uploads.txt 192.168.0.147 1565369 192.168.0.13 1664855 192.168.0.6 1332868 Downloads.txt 192.168.0.147 9838820 192.168.0.18 12051718... (7 Replies)
Discussion started by: zanyspydude
7 Replies

7. Shell Programming and Scripting

Grand totals in awk

I have a one-liner script like this that gives a total of everything in various directories: for i in *; do (cd $i && cd statelist && echo $i && ls -la |awk 'NR>3 {SUM += $5}\ END { print "Total number of elements " SUM }');done It works just great but at the end I want to print a grand... (3 Replies)
Discussion started by: newbie2010
3 Replies

8. UNIX for Beginners Questions & Answers

Ls incorrectly says file not found in sftp.

Hi all When I sftp to an Oracle cloud server, to a folder where there are more than 10k files, and list a small subset of files, it works OK. When I try list more than 10k files, it says file not found. Example output below. (FYI ls/mget with 6k files works OK on this server) Has anyone... (3 Replies)
Discussion started by: pdinsdale
3 Replies

9. Shell Programming and Scripting

Large File masking incorrectly happening Ç delimeter issue

The OS version is Red Hat Enterprise Linux Server release 6.10 I have a script to mask some columns with **** in a data file which is delimeted with Ç , I am using awk for the masking , when I try to mask a small file the awk works fine and masks the required column , but when the file is... (6 Replies)
Discussion started by: LinuxUser8092
6 Replies
Image::ExifTool::AFCP(3)				User Contributed Perl Documentation				  Image::ExifTool::AFCP(3)

NAME
Image::ExifTool::AFCP - Read/write AFCP trailer SYNOPSIS
This module is used by Image::ExifTool DESCRIPTION
This module contains definitions required by Image::ExifTool to extract information from the AFCP trailer. Although the AFCP specification is compatible with various file formats, ExifTool currently only processes AFCP in JPEG images. NOTES
AFCP is a specification which allows meta information (including IPTC) to be appended to the end of a file. It is a poorly designed protocol because (like TIFF) it uses absolute offsets to specify data locations. This is a huge blunder because it makes the AFCP information dependent on the file length, so it is easily invalidated by image editing software which doesn't recognize the AFCP trailer to fix up these offsets when the file length changes. ExifTool will attempt to fix these invalid offsets if possible. Scanning for AFCP information may be time consuming, especially when reading from a sequential device, since the information is at the end of the file. In these instances, the ExifTool FastScan option may be used to disable scanning for AFCP information. AUTHOR
Copyright 2003-2010, Phil Harvey (phil at owl.phy.queensu.ca) This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. REFERENCES
<http://www.tocarte.com/media/axs_afcp_spec.pdf> SEE ALSO
"AFCP Tags" in Image::ExifTool::TagNames, Image::ExifTool(3pm) perl v5.12.1 2010-01-04 Image::ExifTool::AFCP(3)
All times are GMT -4. The time now is 07:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy