Sponsored Content
Top Forums Shell Programming and Scripting Totals in a file - incorrectly displaying Post 302479921 by vgersh99 on Monday 13th of December 2010 09:23:51 AM
Old 12-13-2010
Quote:
Originally Posted by mcclunyboy
AH, I have remember something.

I add the header record myself near the end of the script, by the time I have done this I have already created the trailer record - meaning the total is complete and doesn't use the header.

Anymore thoughts as to why my code is not correctly using 2 decimal places?
Hmmm...... I don't quite understand your question and/or reference to the '2 decimal places'.
Can you maybe rephrase it as I don't see any 'decimal places' - you're dealing with integers.
Does the alternate solution solve your issue?
 

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
fwtmp(8)						      System Manager's Manual							  fwtmp(8)

NAME
fwtmp, acctwtmp, wtmpfix - Modify connect time accounting records to change formats and to make corrections in the records SYNOPSIS
fwtmp [-ic] acctwtmp 'Reason' wtmpfix [File . . .] FLAGS
The fwtmp command accepts ASCII records in the type utmp structure format as input. The fwtmp command converts output to type utmp struc- ture formatted binary records. The fwtmp command converts ASCII type utmp structure formatted input records to binary output records. DESCRIPTION
fwtmp [-ic] The fwtmp command reads records from standard input and writes records to standard output. Normally, information in record fields of the /var/adm/wtmp file is entered as binary data by the init and login programs during the life of the /var/adm/wtmp file. These /var/adm/wtmp file records have nine fields formatted according to members of a type utmp structure defined in the utmp.h include file. The fwtmp command is also capable of writing properly formatted ASCII records from standard input into a file when you use the -i flag. Whenever you enter properly formatted ASCII records for conversion to binary records using the -i flag from the standard input device, you must enter data for each field of the 9-field record in the same order as that of type utmp structure members using a space as a field sep- arator. The following table lists record fields in the order they should be entered, the type utmp structure member name, and the purpose and entry character length. The user login name, which must have exactly sizeof(ut_user) characters. The inittab ID, which must have exactly sizeof(ut_id) characters. The device name, which must have exactly sizeof(ut_line) characters. The process ID, which must have 5 decimal places. The type of entry, which must have 2 decimal places. The type of entry may have any one of several symbolic constant val- ues. The symbolic constants are defined in the utmp.h header file. The process termination status, which must have 4 decimal places. The process exit status, which must have 4 decimal places. The starting time, which must have 10 decimal places. The hostname, which must have exactly sizeof(ut_host) characters. All record field entries you make from standard input must be separated by a space. Also you must fill all string fields with blank charac- ters up to the maximum string size. All decimal values must have the specified number of decimal places with preceding 0s (zeros) to fill empty digit positions. The actual size of character arrays can be found in the utmp.h include file. acctwtmp 'Reason' The acctwtmp command is called by the runacct shell procedure to write a utmp formatted record to standard output with the current date and time together with a 'Reason' string (sizeof(ut_line) characters or less) that you must also enter. wtmpfix [File ...] The wtmpfix command is called by the runacct shell procedure to examine standard input or File records in the wtmp format for corrupted date and timestamp entries. Whenever a corrupted entry is detected, the wtmpfix command corrects date and timestamp inconsistencies and writes corrected records to standard output. Whenever the acctcon1 command runs, and a date and timestamp in a /var/adm/wtmp file is incor- rect, an error is generated when the first corrupted entry is encountered. The acctcon1 process is aborted whenever such an error is detected. The wtmpfix command also checks the validity of the name field to ensure that the name consists only of alphanumeric characters, a $ (dol- lar sign), or spaces. Whenever an invalid name is detected, the wtmpfix command changes the login name to INVALID and writes a diagnostic message to standard error. In this way, the wtmpfix command reduces the likelihood that the acctcon2 command may fail. Each time a date is entered (on system startup or with the date command) a pair of date-change records is written to the /var/adm/wtmp file. The first date-change record is the old date, which is entered with the string old time (the OTIME_MSG string) in the ut_line field and the flag OLD_TIME in the ut_type field. The second record is the new date, which is entered with the string new time (the NTIME_MSG string) in the ut_line field and the flag NEW_TIME in the ut_type field. The wtmpfix command uses these records to synchronize all date and time stamps in the /var/adm/wtmp file. The date-change record pair is then removed. RESTRICTIONS
You should not use the fwtmp command to correct connect-time accounting records because the utmp structure format members are not in the correct order for this operation. EXAMPLES
To convert binary /var/adm/wtmp records in type utmp structure format to an ASCII file called dummy.file, enter a command similar to the following: /usr/sbin/acct/fwtmp < /var/adm/wtmp > dummy.file The content of binary file /var/adm/wtmpfile as input is redirected to dummy.file as ASCII output. To convert records in an ASCII type utmp structure formatted file to a binary output file called /var/adm/wtmp, enter an fwtmp command with the -ic flag similar to the following: /usr/sbin/acct/fwtmp -ic < dummy.file > /var/adm/wtmp The content of ASCII file dummy.file as input is redirected to binary file /var/adm/wtmp as output. FILES
Specifies the command path. Specifies the command path. Specifies the command path. Header file defining structures used to organize login information. Database file for currently logged in users. Login/logout database file. RELATED INFORMATION
Commands: acct(8), acctcon(8), acctmerg(8), date(1), runacct(8) Functions: acct(2) delim off fwtmp(8)
All times are GMT -4. The time now is 12:35 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy