Sponsored Content
Full Discussion: Adding columns of time
Top Forums Shell Programming and Scripting Adding columns of time Post 302728187 by LinuxRacr on Wednesday 7th of November 2012 12:43:50 PM
Old 11-07-2012
Jim,
The solution you provided is not working for me.

rdrtx1, what you provided, I'm not sure if it is accurate or not. I pipe a command (rather than read a file) through what you provided. I am adding the numbers below, and get the following:

Four hours, fifty seven minutes, twenty seven seconds.

The backups for this particular host shows to have started at 04:00:00 and ended at 07:00:35.

004:57:27

Any thoughts? The elapsed times below is what was added...

HHH:MM:SS

Code:
000:00:17
000:00:23
000:00:24
000:00:26
000:00:27
000:00:32
000:00:35
000:00:38
000:00:40
000:00:45
000:00:46
000:00:47
000:00:47
000:00:49
000:00:49
000:00:50
000:00:50
000:00:50
000:00:51
000:00:52
000:00:53
000:00:53
000:00:55
000:00:55
000:00:58
000:00:58
000:01:00
000:01:00
000:01:01
000:01:03
000:01:04
000:01:06
000:01:06
000:01:06
000:01:08
000:01:08
000:01:09
000:01:10
000:01:10
000:01:12
000:01:12
000:01:12
000:01:13
000:01:13
000:01:14
000:01:15
000:01:15
000:01:17
000:01:18
000:01:18
000:01:21
000:01:22
000:01:24
000:01:24
000:01:33
000:01:44
000:02:02
000:02:07
000:02:19
000:02:20
000:02:33
000:03:49
000:04:05
000:04:10
000:04:20
000:05:24
000:05:57
000:08:17
001:00:35

Here is the code:
Code:
#!/bin/ksh

CLIENT3="server12"
TOTAL_CLIENT_ELAPSED=$(egrep -v "JobID" ${RPT_CSV} | egrep ${CLIENT3} | awk -F "," '{print $16}'| sort -n | awk -F: '
{ s+=$3; m+=$2; h+=$1; }
END {
  if (int(s/60)>0) {m+=int(s/60); s=s%60;}
  if (int(m/60)>0) {h+=int(m/60); m=m%60;}
  printf "%03d:%02d:%02d\n", h, m, s;
}')

CLIENT_START_TIME=$(egrep -v "JobID" ${RPT_CSV} | egrep ${CLIENT3} | awk -F "," '{print $13}' | sort -n | head -1)
CLIENT_END_TIME=$(egrep -v "JobID" ${RPT_CSV} | egrep ${CLIENT3} | awk -F "," '{print $15}' | sort -n | tail -1)

echo "Client StartTime EndTime TotalElapsed" | tr -s " " ","
echo "${CLIENT3} ${CLIENT_START_TIME} ${CLIENT_END_TIME} ${TOTAL_CLIENT_ELAPSED}" | tr -s " " ","

Output:
Code:
Client,StartTime,EndTime,TotalElapsed
server12,04:00:00,07:00:35,004:57:27


Last edited by LinuxRacr; 11-07-2012 at 01:57 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Adding columns in csv

I have the following data in FILE1.CSV: code: Amount1: Amount2: xxxxx ,, 200 ,,400 yyxxa ,,200 bbcgu ,,2500 ,,300 i want to be able to produce the following FILE2.CSV: code: Amount xxxxx ,, 600... (7 Replies)
Discussion started by: chachabronson
7 Replies

2. UNIX for Dummies Questions & Answers

Adding columns to a file

I want to select the first column from a daily file called foo.csv. The result is written to file foo.txt. Currently the following script is used for that: cut -d, -f 1 foo.csv > foo.txt A typical result would yield : A12 A45 B11 B67 What needs to happen in addition is that two columns... (5 Replies)
Discussion started by: figaro
5 Replies

3. Shell Programming and Scripting

adding columns

Hey everyone! I have a need to add 2 files together as columns. For instance, I have one file that has several rows of data and I want to take data from another file and add Line 1 to the end of Line1 in the first file file1 line1.........file2 line1 file1 line2.........file2 line2... (12 Replies)
Discussion started by: Kelam_Magnus
12 Replies

4. Shell Programming and Scripting

Adding columns of two files

Hello everyone, I have two files containing 6 columns and thousands of rows. I want to add them (i.e. first column of first file + first column of second file and so on) and print the output in a third file. Can you please help me. Thanks a lot (7 Replies)
Discussion started by: chandra321
7 Replies

5. UNIX for Dummies Questions & Answers

Adding loads of columns

Hi All, I've got file1 like this: aaa bbb ccc ddd eee fff ggg hhh kkk ppp mmm nnn and file 2 like this: aaa qqq www ddd fff ggg ggg sss zzz ppp vvv yyy and file 3 like this: aaa ggg ppp I need to match the first column of file3 and file1, then add the rest of the file 1 to... (3 Replies)
Discussion started by: zajtat
3 Replies

6. Shell Programming and Scripting

sorting and adding columns

i have a file with two columns, and i want to uniquely sort the values in fist column and add the corresponding values in the second columns eg file a contents tom 200 john 300 sow 500 tom 800 james 50 sow 300 output shpould be in file b as tom 1000 john 300 sow 800 james 50 (0 Replies)
Discussion started by: dealerso
0 Replies

7. Shell Programming and Scripting

Help with ask adding columns

Hello, I am using AWK in UBUNTU 12.04. I have a dataset as follows: 1 2 12 1 4 1 4 1 7 9 4 6 1 2 4 5 7 8 45 7 4 5 7 5 What I want to do is to add the values of some columns to each other and print it in the same file as the new column while omitting the previous two columns to have... (3 Replies)
Discussion started by: Homa
3 Replies

8. Shell Programming and Scripting

Adding time to date time in UNIX shell scipting

I needed some help in adding a duration (in seconds) to a start time (in hhmmss format) and a start date (in mmddyy format) in order to get an end date and end time. The concept of a leap year is also to be considered while incrementing the day. The code/ function that I have formed so far is as... (3 Replies)
Discussion started by: codehelp04
3 Replies

9. Shell Programming and Scripting

Adding columns with values dependent on existing columns

Hello I have a file as below chr1 start ref alt code1 code2 chr1 18884 C CAAAA 2 0 chr1 135419 TATACA T 2 0 chr1 332045 T TTG 0 2 chr1 453838 T TAC 2 0 chr1 567652 T TG 1 0 chr1 602541 ... (2 Replies)
Discussion started by: plumb_r
2 Replies

10. Shell Programming and Scripting

Adding columns from 2 files with variable number of columns

I have two files, file1 and file2 who have identical number of rows and columns. However, the script is supposed to be used for for different files and I cannot know the format in advance. Also, the number of columns changes within the file, some rows have more and some less columns (they are... (13 Replies)
Discussion started by: maya3
13 Replies
BYTEPREFIX(5)							File Formats Manual						     BYTEPREFIX(5)

NAME
byteprefix - Configuration for display of sizes DESCRIPTION
There are two standard ways to use units in computing: base 10 (1 k = 10^3 = 1 000) and base 2 (1 K = 2^10 = 1 024). Historically, most computer programs have used units in base 2, where 1 KB = 1 024 bytes, 1 MB = 1 048 576 bytes, etc. However, users are more likely to expect and understand sizes in base 10, as this is the norm outside of computing. This configuration file is a method for configuring programs (that use libkibi) to display sizes in the user's preferred style. It can be configured through a configuration file or environment variable (which takes precedence). When not using the "historic" style, IEC-style prefixes (KiB, MiB, etc.) are used for base 2 units, to disambiguate them from base 10 units (kB, MB, etc.). OPTIONS
There are three possible styles (Default: base10): base2 Display all sizes in Base 2 with IEC prefixes. 1 KiB = 1 024 bytes. 1 MiB = 1 024 KiB = 1 048 576 bytes. 1 GiB = 1 024 MiB = 1 048 576 KiB = 1 073 741 824 bytes. base10 Display all sizes in Base 10, except for sizes of RAM, which use base 2 with IEC prefixes. Everything except RAM: 1 kB = 1 000 bytes. 1 MB = 1 000 kB = 1 000 000 bytes. 1 GB = 1 000 MB = 1 000 000 kB = 1 000 000 000 bytes. RAM: 1 KiB = 1 024 bytes. 1 MiB = 1 024 KiB = 1 048 576 bytes. 1 GiB = 1 024 MiB = 1 048 576 KiB = 1 073 741 824 bytes. historic Display all sizes in Base 2, without IEC prefixes. 1 KB = 1 024 bytes. 1 MB = 1 024 KB = 1 048 576 bytes. 1 GB = 1 024 MB = 1 048 576 KB = 1 073 741 824 bytes. Not recommended. This style uses base units 2 with prefixes usually associated with base 10 units. While it uses KB rather than the SI (base 10) kB, there is no such distinction beyond the kilobyte range, and the units are ambiguous. ENVIRONMENT
BYTEPREFIX This environment variable will override the configured or default style. It should just contain one of the style names, listed in OPTIONS above. XDG_CONFIG_HOME The location of the user's configuration files. If not set, it will be assumed to be ~/.config. FILES
The preferred style can be set in a system-wide configuration file and/or in user's own configuration file (which will take precedence). If no configuration file exists, the default style is base10. /etc/byteprefix or XDG_CONFIG_HOME/byteprefix This file should contain a single line: format=style. Lines beginning with # are treated as comments. EXAMPLE
A user wanting base 2 display can set the following in ~/.config/byteprefix: format=base2 SEE ALSO
units(7) libkibi January 2011 BYTEPREFIX(5)
All times are GMT -4. The time now is 04:46 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy