Sponsored Content
Full Discussion: Compare Timestamps
Top Forums Shell Programming and Scripting Compare Timestamps Post 302446060 by rexpokinghorn on Tuesday 17th of August 2010 02:26:13 PM
Old 08-17-2010
Compare Timestamps

Hi! Long time reader first time registered user and poster.

I've picked up some times and tricks and I'm at a dead end... I've parsed a log file for duplicates and printed only the two fields I need (duplicate entry and time stamp).

My question is, with this output, how would I script something that will compare every two lines and tell me if the timestamp is within 5 minutes of each other:

Code:
for i in `cat numberstest` ; do less test2.txt | grep $i | awk -F " " '{print $3 " " $13}' ; done
05:11:13 ani='13479981111',
05:12:57 ani='13479981111',
16:01:55 ani='14013472222',
16:03:41 ani='14013472222',
14:02:45 ani='19095753333',
15:07:51 ani='19095753333',

Thanks for looking! Smilie

Last edited by Scott; 08-17-2010 at 03:38 PM.. Reason: Added code tags
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Unix timestamps

Can someone help me with a Unix or perl script to convert the unix timestamps to human readable format? Any help will be highly appreciated... (3 Replies)
Discussion started by: hamsasal
3 Replies

2. Solaris

Difference between two timestamps

I'm writting a script to find the difference between two timestamp. One field i get on delivery time of the file like 07:17 AM and other is my SLA time 06:30 AM I need to find the difference between these two time (time exceeded to meet SLA). Need some suggestions. (8 Replies)
Discussion started by: raman1605
8 Replies

3. Shell Programming and Scripting

timestamps

Hello! I have the following problem. I read a file using perl, each line of this file has the fllowing format. 14/4/2008 8:42:03 πμ|10800|306973223399|4917622951117|1||1259|1|126|492|433||19774859454$ Th first field is the timestamp and the second field is the offset in seconds. How can... (1 Reply)
Discussion started by: chriss_58
1 Replies

4. Shell Programming and Scripting

Arithmetic on timestamps

Hi Friends, please advise on shell script to add two time stamps for example : a=12:32 b=12:00 c=a+b=00:32 please help me to find shell script to add to two time stamps, as i need to convert time from EST to GMT or SST to prepare status of jobs in unix and to specify estimated time to... (3 Replies)
Discussion started by: balireddy_77
3 Replies

5. Shell Programming and Scripting

perl - Error trying to compare timestamps

Hello, I have the following snippet of code: my $Temp=""; 239 #Fix Timestamp 240 #-------------------------------------------------------------------------------- 241 @initial_date=split(/ /, $field); 242 ... (1 Reply)
Discussion started by: chriss_58
1 Replies

6. UNIX for Dummies Questions & Answers

Compare 2 timestamps

Hi, i have current timestamp, lets say "12:02:45" in an variable (var1) and another timestamp "08:30:00" fetched from table in another variable2 (var2). How do i compare 2 timestamps in unix shell scripting. if var 1 > var 2 then echo message. Thanks in advance. (3 Replies)
Discussion started by: prasannarajesh
3 Replies

7. Shell Programming and Scripting

Help with touch and timestamps

Hello fellow Unix geeks, I have been given a very urgent assignment in my office on writing a particular Shell script but I'm very much new to it.I would appreciate any help from you on solving this problem--which might seem very trivial to you. The Unix flavour is a Sun Solaris one..(not... (6 Replies)
Discussion started by: Digjoy83
6 Replies

8. Shell Programming and Scripting

Comparing two timestamps

Hi all!!, I'm using Ksh and working on Linux. I want to compare two timestamps, timestamp1 and timestamp2. Until, timestamp1 is lesser than timestamp2, i want to do something, lets say print something. The code i have written is: a=`date +%H:%M:%S` b=`date +%H:%M:%S -d" 1... (1 Reply)
Discussion started by: Jayaraman
1 Replies

9. Shell Programming and Scripting

Compare two timestamps and print elapsed time

Hi, I am unable to Difference between two time stamps in Linux and display the total elapsed time . Source date: Aug 15, 2012 02:00:03 Target date: Aug 14, 2012 18:00:03 # based on the forums I am using the below function. Converted dates into this format Src_dt=20120814180003... (7 Replies)
Discussion started by: onesuri
7 Replies

10. Shell Programming and Scripting

Write with a look for timestamps

hello i'm using SOX to generate a spectrogram from a wave file with the command : #sox file.wav -n spectrogram is there a way to create a spectrogram using the same command but reading file timestamps instead of the namefile.wav , since name is changing every 4 hours? (it's saved with... (2 Replies)
Discussion started by: Board27
2 Replies
CGI::Push(3pm)						 Perl Programmers Reference Guide					    CGI::Push(3pm)

NAME
CGI::Push - Simple Interface to Server Push SYNOPSIS
use CGI::Push qw(:standard); do_push(-next_page=>&next_page, -last_page=>&last_page, -delay=>0.5); sub next_page { my($q,$counter) = @_; return undef if $counter >= 10; return start_html('Test'), h1('Visible')," ", "This page has been called ", strong($counter)," times", end_html(); } sub last_page { my($q,$counter) = @_; return start_html('Done'), h1('Finished'), strong($counter - 1),' iterations.', end_html; } DESCRIPTION
CGI::Push is a subclass of the CGI object created by CGI.pm. It is specialized for server push operations, which allow you to create ani- mated pages whose content changes at regular intervals. You provide CGI::Push with a pointer to a subroutine that will draw one page. Every time your subroutine is called, it generates a new page. The contents of the page will be transmitted to the browser in such a way that it will replace what was there beforehand. The tech- nique will work with HTML pages as well as with graphics files, allowing you to create animated GIFs. Only Netscape Navigator supports server push. Internet Explorer browsers do not. USING CGI
::Push CGI::Push adds one new method to the standard CGI suite, do_push(). When you call this method, you pass it a reference to a subroutine that is responsible for drawing each new page, an interval delay, and an optional subroutine for drawing the last page. Other optional parameters include most of those recognized by the CGI header() method. You may call do_push() in the object oriented manner or not, as you prefer: use CGI::Push; $q = new CGI::Push; $q->do_push(-next_page=>&draw_a_page); -or- use CGI::Push qw(:standard); do_push(-next_page=>&draw_a_page); Parameters are as follows: -next_page do_push(-next_page=>&my_draw_routine); This required parameter points to a reference to a subroutine responsible for drawing each new page. The subroutine should expect two parameters consisting of the CGI object and a counter indicating the number of times the subroutine has been called. It should return the contents of the page as an array of one or more items to print. It can return a false value (or an empty array) in order to abort the redrawing loop and print out the final page (if any) sub my_draw_routine { my($q,$counter) = @_; return undef if $counter > 100; return start_html('testing'), h1('testing'), "This page called $counter times"; } You are of course free to refer to create and use global variables within your draw routine in order to achieve special effects. -last_page This optional parameter points to a reference to the subroutine responsible for drawing the last page of the series. It is called after the -next_page routine returns a false value. The subroutine itself should have exactly the same calling conventions as the -next_page routine. -type This optional parameter indicates the content type of each page. It defaults to "text/html". Normally the module assumes that each page is of a homogenous MIME type. However if you provide either of the magic values "heterogeneous" or "dynamic" (the latter provided for the convenience of those who hate long parameter names), you can specify the MIME type -- and other header fields -- on a per-page basis. See "heterogeneous pages" for more details. -delay This indicates the delay, in seconds, between frames. Smaller delays refresh the page faster. Fractional values are allowed. If not specified, -delay will default to 1 second -cookie, -target, -expires, -nph These have the same meaning as the like-named parameters in CGI::header(). If not specified, -nph will default to 1 (as needed for many servers, see below). Heterogeneous Pages Ordinarily all pages displayed by CGI::Push share a common MIME type. However by providing a value of "heterogeneous" or "dynamic" in the do_push() -type parameter, you can specify the MIME type of each page on a case-by-case basis. If you use this option, you will be responsible for producing the HTTP header for each page. Simply modify your draw routine to look like this: sub my_draw_routine { my($q,$counter) = @_; return header('text/html'), # note we're producing the header here start_html('testing'), h1('testing'), "This page called $counter times"; } You can add any header fields that you like, but some (cookies and status fields included) may not be interpreted by the browser. One interesting effect is to display a series of pages, then, after the last page, to redirect the browser to a new URL. Because redirect() does b<not> work, the easiest way is with a -refresh header field, as shown below: sub my_draw_routine { my($q,$counter) = @_; return undef if $counter > 10; return header('text/html'), # note we're producing the header here start_html('testing'), h1('testing'), "This page called $counter times"; } sub my_last_page { return header(-refresh=>'5; URL=http://somewhere.else/finished.html', -type=>'text/html'), start_html('Moved'), h1('This is the last page'), 'Goodbye!' hr, end_html; } Changing the Page Delay on the Fly If you would like to control the delay between pages on a page-by-page basis, call push_delay() from within your draw routine. push_delay() takes a single numeric argument representing the number of seconds you wish to delay after the current page is displayed and before displaying the next one. The delay may be fractional. Without parameters, push_delay() just returns the current delay. INSTALLING CGI
::Push SCRIPTS Server push scripts must be installed as no-parsed-header (NPH) scripts in order to work correctly on many servers. On Unix systems, this is most often accomplished by prefixing the script's name with "nph-". Recognition of NPH scripts happens automatically with WebSTAR and Microsoft IIS. Users of other servers should see their documentation for help. Apache web server from version 1.3b2 on does not need server push scripts installed as NPH scripts: the -nph parameter to do_push() may be set to a false value to disable the extra headers needed by an NPH script. AUTHOR INFORMATION
Copyright 1995-1998, Lincoln D. Stein. All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Address bug reports and comments to: lstein@cshl.org BUGS
This section intentionally left blank. SEE ALSO
CGI::Carp, CGI perl v5.8.0 2002-06-01 CGI::Push(3pm)
All times are GMT -4. The time now is 05:59 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy