Sponsored Content
Top Forums Shell Programming and Scripting ksh to get longest timediff report? Post 302586976 by sabercats on Tuesday 3rd of January 2012 08:14:33 PM
Old 01-03-2012
ksh to get longest timediff report?

Hi all,

I have a report.log
Code:
1,BEAR,2011-11-21 08:49:16.000,2011-11-21 08:53:13.910,San Francisco,,,
2,BEAR,2011-11-21 08:49:16.000,2011-11-21 12:50:31.550,San Francisco,,,
3,BEAR,2011-11-21 08:49:16.000,2011-11-21 08:49:19.987,San Francisco,,,
4,HAWK,2011-11-21 10:36:26.000,2011-11-21 10:45:11.823,Los Angeles,,,
5,HAWK,2011-11-21 10:36:26.000,2011-11-21 12:41:17.763,Los Angeles,,,
6,HAWK,2011-11-21 10:41:12.000,2011-11-21 10:55:08.393,San Francisco,,,
7,HAWK,2011-11-21 10:41:12.000,2011-11-21 15:46:24.707,San Francisco,,,
8,HAWK,2011-11-21 10:41:12.000,2011-11-22 11:09:13.907,San Francisco,,,

How do you write a shell script to get from report.log and write to result.log? Thanks
Which team , location and how long? (longest time end time - start time)
Example:
Code:
BEAR,San Francisco, timediff (2011-11-21 12:50:31.550 - 2011-11-21 08:49:16.000) in hours
HAWK,Los Anegles, timediff (2011-11-21 12:41:17.763 - 2011-11-21 10:36:26.000) in hours
HAWK,San Francisco, timediff (2011-11-22 11:09:13.907 - 2011-11-21 10:41:12.000) in hours


Last edited by Franklin52; 01-04-2012 at 03:39 AM.. Reason: Please use code tags for code and data samples, thank you
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

TimeDiff function?

Hi, Is there any function in Unix that could get the Time Differrence of two values? this would be used as statistic for how long a job completes, from start to finish.. Please help. thanks, Jet (12 Replies)
Discussion started by: kakashi_jet
12 Replies

2. UNIX for Advanced & Expert Users

in sed ,to get longest word

i want the longest word from the file using sed. can any one help me in this case? (6 Replies)
Discussion started by: lakshmananindia
6 Replies

3. Shell Programming and Scripting

Find the length of the longest line

Dear All, To find the length of the longest line from a file i have used wc -L which is giving the proper output... But the problem is AIX os does not support wc -L command. so is there any other way 2 to find out the length of the longest line using awk or sed ? Regards, Pankaj (1 Reply)
Discussion started by: panknil
1 Replies

4. Shell Programming and Scripting

shell script: longest match from right?

Return the position of matched string from right, awk match can do from left only. e.g return pos 7 for search string "service" from "AA-service" or return the matched string "service", then caculate the string length. Thanks!. (3 Replies)
Discussion started by: honglus
3 Replies

5. Shell Programming and Scripting

longest, shortest, map wrong

Hi Everyone, a.txt cola,colb1111 601030,CEL 6031,CEL 60103,CEL Would like to find the longest field colb1111, and shortest, so the output is 6, 4 my code: #!/usr/bin/perl use strict; use warnings; my %prefix_to_contry = (); my $key; open(FH,'/root/a.txt') or die "$!"; (0 Replies)
Discussion started by: jimmy_y
0 Replies

6. Shell Programming and Scripting

Finding longest line in a Record

Good Morning/Afternoon All, I am using the nawk utility in korn shell to find the longest field and display that result. My Data is as follows: The cat ran The elephant ran Milly ran too We all ran I have tried nawk '{ if (length($1) > len) len=length($1); print $1}' filename The... (5 Replies)
Discussion started by: SEinT
5 Replies

7. Shell Programming and Scripting

Longest length of string in array

I would be grateful if someone could help me. I am trying to write a .sh script in UNIX. I have the following code; User=john User=james User=ian User=martin for x in ${User} do print ${#x} done This produces the following output; 4 5 3 6 (12 Replies)
Discussion started by: mmab
12 Replies

8. Shell Programming and Scripting

Longest word in a file

I am trying to write a command on just one line, i.e seperated by ';' and '|' etc, that finds the number of characters in the longest word of a file, preferably using the 'tr' and 'wc' commands. i no that wc shows the number of lines words and characters in a file but im not sure how to use it... (5 Replies)
Discussion started by: scotty85
5 Replies

9. Shell Programming and Scripting

HTML Report from mail in ksh 88

Hi Team, I'm trying to send HTML Report from email using the below script (Using ksh 88 version) #!/bin/ksh set -x SUB="Test Email" Mail_Body="This is for testing" Send_Mail_HTML() { ( echo "FROM: abcd@test.com" echo "To: abcd@test.com" echo "Subject:... (2 Replies)
Discussion started by: smile689
2 Replies

10. Shell Programming and Scripting

Parsing the longest match substring

Hello gurus, I have a database of possible primary signal strings pp22 pt22dx pp22dx jty2234 Also I have a list of scrambled signals which has a shorter string and a longer string separated by // (double slash ). Always the shorter string of a scrambled signal will have the primary... (6 Replies)
Discussion started by: senhia83
6 Replies
COMPACT(3)								 1								COMPACT(3)

compact - Create array containing variables and their values

SYNOPSIS
array compact (mixed $varname1, [mixed $...]) DESCRIPTION
Creates an array containing variables and their values. For each of these, compact(3) looks for a variable with that name in the current symbol table and adds it to the output array such that the variable name becomes the key and the contents of the variable become the value for that key. In short, it does the opposite of extract(3). Any strings that are not set will simply be skipped. PARAMETERS
o $varname1 -compact(3) takes a variable number of parameters. Each parameter can be either a string containing the name of the variable, or an array of variable names. The array can contain other arrays of variable names inside it; compact(3) handles it recursively. RETURN VALUES
Returns the output array with all the variables added to it. EXAMPLES
Example #1 compact(3) example <?php $city = "San Francisco"; $state = "CA"; $event = "SIGGRAPH"; $location_vars = array("city", "state"); $result = compact("event", "nothing_here", $location_vars); print_r($result); ?> The above example will output: Array ( [event] => SIGGRAPH [city] => San Francisco [state] => CA ) NOTES
Note Gotcha Because variable variables may not be used with PHP's Superglobal arrays within functions, the Superglobal arrays may not be passed into compact(3). SEE ALSO
extract(3). PHP Documentation Group COMPACT(3)
All times are GMT -4. The time now is 07:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy