Sponsored Content
Top Forums Shell Programming and Scripting Grep content between timestamp Post 302463566 by summer_cherry on Monday 18th of October 2010 03:23:57 AM
Old 10-18-2010
Code:
my ($pre,$cur);
while(<DATA>){
  if (/([0-9]{2})\/([0-9]{2})\/([0-9]{4})\s+([0-9]{2}):([0-9]{2})/){
    $temp = $3."_".$2."_".$1."_".$4."_".$5;
    if($.==1){
       $cur = $temp;
       $pre = $temp;
    }
    else{
      $cur = $temp;
      my $tmp = ${pre}."-".$cur.".leo";
      open FH,">$tmp";
      print FH @{$hash{$pre}};
      close FH;
      @{$hash{$temp}}=(@{$hash{$pre}});
      $pre = $temp;
    }
    next;
  }
  else{
    push @{$hash{$temp}},$_;
  }
}
my $temp=${pre}."_now.leo";
open FH,">$temp";
print FH @{$hash{$pre}};
close FH;
__DATA__
29/09/2010 00:30
line 1
line 2
29/09/2010 01:00
line 3
line 4
29/09/2010 01:30
line 5
line 6
29/09/2010 02:30
line 7
line 8

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to grep the logs for two particular timestamp

Hi, could anyone help me out how to write a script, to grep the two timestamp from a particular file, so that it will list out all the logs between the particular timestamp I have a pattern of log: servicename operationname starttime endtime eg., servicename1 operationname1 01:11:11... (1 Reply)
Discussion started by: jacktolearn
1 Replies

2. AIX

how to grep and compare timestamp in a file with the current date

I want to read a log file from a particular location.In the logfile , lines contains timestamp.I need to compare the timestamp in the logfile with the current date.If the timpestamp in the log file is less than 4 hours then i need to read the file from that location.Below is the file format.Please... (1 Reply)
Discussion started by: achu
1 Replies

3. AIX

how to grep and compare timestamp in a file with the current date

I want to read a log file from a particular location.In the log file each line starts with timestamp.I need to compare the timestamp in the logfile with the current date.If the timpestamp in the log file is less than 4 hours then i need to read the file from that location.Below is the file... (1 Reply)
Discussion started by: achu
1 Replies

4. UNIX for Dummies Questions & Answers

Append file with grep output but add timestamp?

I've setup a cron job that greps a file every five minutes and then writes (appends) the grep output/result to another file: grep "monkey" zoo.log | tail -1 >> cron-zoo-log Is there any way I can add the date and time (timestamp) to the cron-zoo-log file for each time a new line was added? ... (12 Replies)
Discussion started by: Sepia
12 Replies

5. Shell Programming and Scripting

how to get tags content by grep

1) Is it possible to get tags content by grep -E ? For example title. Source text "<title>My page<title>"; to print "My page". 2) which bash utility to use when I want to use regex in this format? (?<=title>).*(?=</title) (11 Replies)
Discussion started by: visitor123
11 Replies

6. Shell Programming and Scripting

How to grep the content performed by an User

I want to grep the content performed by an User from a file. Suppose that i have a following file HYD-HMS-2$ ls -lrt -rw-r--r-- 1 sdfrun sdf 31726356 Aug 1 13:04 journal.03.01082012.19.csv I could able to grep the content performed by a user by "sed" command as follows HYD-HMS-2$... (0 Replies)
Discussion started by: duppalav
0 Replies

7. Shell Programming and Scripting

How to sort grep result based on timestamp?

Hi, Trying to sort grep result based on timestamp of the filename. I have the following result and want to sort them on timestampgrep -i 'ERROR' *log*2013* s_m_xxx_xxx_xxx_xxx_xxxx.log.20130906092431:TRANSF_1_1_1> DBG_21216 Finished transformations for Source Qualifier . Total errors ... (5 Replies)
Discussion started by: bobbygsk
5 Replies

8. UNIX for Dummies Questions & Answers

Grep content in xml file

I have an xml file with header as below. <Provider xmlns="http://www.xyzx.gov/xyz" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.xyzx.gov/xyz xyz.xsd" SCHEMA_VERSION="2.5" PROVIDER="5"> I want to get the schema version here that is 2.5 and put in a... (7 Replies)
Discussion started by: Ariean
7 Replies

9. Shell Programming and Scripting

Append timestamp create .trg file for all content of an unzipped archive

Hi, I have a test.zip archive that contains test.zip --> (file_1.txt, file_2.txt , file_3.txt) I need to unzip the file like this, file_1_timestamp.txt file_1_timestamp.trg file_2_timestamp.txt file_2_timestamp.trg file_3_timestamp.txt file_3_timestamp.trg Could you please let me know... (7 Replies)
Discussion started by: Shandel
7 Replies

10. Shell Programming and Scripting

Grep lines between last hour timestamp and current timestamp

So basically I have a log file and each line in this log file starts with a timestamp: MON DD HH:MM:SS SEP 15 07:30:01 I need to grep all the lines between last hour timestamp and current timestamp. Then these lines will be moved to a tmp file from which I will grep for particular strings. ... (1 Reply)
Discussion started by: nms
1 Replies
xclock(1X)																xclock(1X)

NAME
xclock - analog / digital clock for X SYNOPSIS
xclock [-help] [-analog] [-digital] [-chime] [-hd color] [-hl color] [-update seconds] [-padding number] OPTIONS
xclock accepts all of the standard X Toolkit command line options along with the additional options listed below: This option indicates that a brief summary of the allowed options should be printed on the standard error. This option indicates that a conventional 12 hour clock face with tick marks and hands should be used. This is the default. This option indicates that a 24 hour digital clock should be used. This option indicates that the clock should chime once on the half hour and twice on the hour. This option specifies the color of the hands on an analog clock. The default is black. This option specifies the color of the edges of the hands on an analog clock, and is only useful on color displays. The default is black. This option specifies the frequency in seconds at which xclock should update its display. If the clock is obscured and then exposed, it will be updated immediately. A value of 30 seconds or less will enable a second hand on an analog clock. The default is 60 seconds. This option specifies the width in pixels of the padding between the window border and clock text or picture. The default is 10 on a digital clock and 8 on an analog clock. DESCRIPTION
The xclock program displays the time in analog or digital form. The time is continuously updated at a frequency which may be specified by the user. X DEFAULTS
This program uses the Clock widget. It understands all of the core resource names and classes as well as: Specifies the width of the clock. The default for analog clocks is 164 pixels; the default for digital clocks is whatever is needed to hold the clock when displayed in the chosen font. Specifies the height of the clock. The default for analog clocks is 164 pixels; the default for digital clocks is whatever is needed to hold the clock when displayed in the chosen font. Specifies the frequency in seconds at which the time should be redisplayed. Specifies the color for the tic marks. The default depends on whether reverseVideo is specified. If reverseVideo is speci- fied the default is lwhite, otherwise the default is black. Specifies the color of the insides of the clock's hands. The default depends on whether reverseVideo is specified. If reverseVideo is specified the default is lwhite, otherwise the default is black. Specifies the color used to highlight the clock's hands. The default depends on whether reverseVideo is specified. If reverseVideo is specified the default is lwhite, otherwise the default is black. Specifies whether or not an analog clock should be used instead of a digital one. The default is True. Specifies whether or not a bell should be rung on the hour and half hour. Specifies the amount of internal padding in pixels to be used. The default is 8. Specifies the font to be used for the digital clock. Note that variable width fonts currently will not always display correctly. WIDGETS
In order to specify resources, it is useful to know the hierarchy of the widgets which compose xclock. In the notation below, indentation indicates hierarchical structure. The widget class name is given first, followed by the widget instance name. XClock xclock Clock clock ENVIRONMENT
to get the default host and display number. to get the name of a resource file that overrides the global resources stored in the RESOURCE_MANAGER property. FILES
specifies required resources BUGS
xclock believes the system clock. When in digital mode, the string should be centered automatically. SEE ALSO
X(1X), xrdb(1X), time(3) AUTHORS
Tony Della Fera (MIT-Athena, DEC) Dave Mankins (MIT-Athena, BBN) Ed Moy (UC Berkeley) xclock(1X)
All times are GMT -4. The time now is 03:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy