Sponsored Content
Top Forums Shell Programming and Scripting parse a log file and remember last line Post 302448640 by bartus11 on Thursday 26th of August 2010 01:31:48 PM
Old 08-26-2010
You can try something like that:
Code:
#!/bin/ksh
while :; do
temp=$(tail -1 /your/log/file)
awk "/$last/{p=1}p" /your/log/file #pipe output of that command to your parser
last=$temp
sleep 300
done

To test if it is working correctly, you can do something like:
Code:
#!/bin/ksh
while :; do
temp=$(tail -1 /your/log/file)
echo "============================================="
awk "/$last/{p=1}p" /your/log/file
last=$temp
sleep 300
done

Then new entries should be printed continously every 5 mins, separated from the old ones by "======".
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

remember last visited line in vim

hi, I know we can do this; but dont know how.. I open a file using vim..browse thru it and then say :wq after reaching some line; The next time I open the same file, I want vim to position the cursor on the line where I left last time; anyone? (2 Replies)
Discussion started by: spopuri
2 Replies

2. UNIX for Advanced & Expert Users

how do you parse 1 line at a time of file1 ie. line(n) each line into new file

File 1 <html>ta da....unique file name I want to give file=>343...</html> <html>da ta 234 </html> <html>pa da 542 </html> and so on... File 2 343 234 542 and so on, each line in File 1 one also corresponds with each line in File 2 I have tried several grep, sed, while .. read, do,... (4 Replies)
Discussion started by: web_developer
4 Replies

3. Shell Programming and Scripting

Parse file from 2nd line in shell script

Hi, I need to parse input file from 2nd line. Input file contents are, ABC123;20100913115432;2000000;NO; 04;AAA;09;DDD;601020304;AAAA;1;OPTA1;OPTA2;;; 04;BBB;09;BBB;601020304;BBBB;0;OPTB1;OPTB2;OPTB3;OPTB4;OPTB5; 04;CCC;09;DDD;601020304;CCCC;1;;;;; For each line, 1] I need to check... (17 Replies)
Discussion started by: Poonamol
17 Replies

4. Shell Programming and Scripting

Parse the log file

./abc.sh started at Sun Oct 24 06:42:04 PDT 2010 Message: ======= Summary Report of NAME count ----------------------------------------------------------------- Below is the output of the SQL query :- NAME COUNT... (2 Replies)
Discussion started by: sandy1028
2 Replies

5. Shell Programming and Scripting

Parse configuration file & add line in particular section

Greetings, I recently built a replicated DRBD, Heartbeat, & iSCSI Target Initiator storage server on Ubuntu 10.04 to offer shared storage to server Vmware ESX and Microsoft Clusters. Everything works flawlessly, however I wanted to make a script to create, remove, grow volumes to offer ESX... (6 Replies)
Discussion started by: Aeudian
6 Replies

6. Shell Programming and Scripting

Parse large file on line count (random lines)

I have a file that needs to be parsed into multiple files every time there line contains a number 1. the problem i face is the lines are random and the file size is random. an example is that on line 4, 65, 187, 202 & 209 are number 1's so there has to be file breaks between all those to create 4... (6 Replies)
Discussion started by: darbs121
6 Replies

7. Shell Programming and Scripting

Parse a single line file and store value.

I have a single line file like this : Average Fragmentation Quotient : 3.084121 Now I want to store the value which comes after ":" i,e 3.084121 into a variable. And if this variable crosses above 6 i want to call another script... can any one help me on this... (7 Replies)
Discussion started by: Hyp_Todd
7 Replies

8. Shell Programming and Scripting

SH script to parse string and return multi-line file

Hello all, I have been asked to exercise my shell scripting and it has been 10 plus years since I used to do it so I can not remember hardly anything and ask for your help. What I need to do is copy a line out of a file that can be 10 to 100 characters long, I then need to parse this line into... (3 Replies)
Discussion started by: Alivadoro
3 Replies

9. Shell Programming and Scripting

Parse A Log File

Hello All, Below is the excerpt from my Informatica log file which has 4 blocks of lines (starting with WRITER_1_*_1). Like these my log file will have multiple blocks of same pattern. WRITER_1_*_1> WRT_8161 TARGET BASED COMMIT POINT Thu May 08 09:33:21 2014... (13 Replies)
Discussion started by: Ariean
13 Replies

10. Post Here to Contact Site Administrators and Moderators

Log Out vs Remember Me

Howdy, I clicked the rememberer me when I log in, and evidently I really do not understand what that means. I had hoped that at least it would remember my user name for the next time that I log in. However, when I log out, I see a message about cookies being removed and one other thing that I... (1 Reply)
Discussion started by: danuke
1 Replies
DPKG::Log(3pm)						User Contributed Perl Documentation					    DPKG::Log(3pm)

NAME
DPKG::Log - Parse the dpkg log VERSION
version 1.20 SYNOPSIS
use DPKG::Log; my $dpkg_log = DPKG::Log->new('filename' => 'dpkg.log', 'parse' => 1); DESCRIPTION
This module is used to parse a logfile and store each line as a DPKG::Log::Entry object. METHODS
$dpkg_log = DPKG::Log->new() $dpkg_log = DPKG::Log->new('filename' => 'dpkg.log') $dpkg_log = DPKG::Log->new('filename' => 'dpkg.log', 'parse' => 1 ) Returns a new DPKG::Log object. If parse is set to a true value the logfile specified by filename is parsed at the end of the object initialisation. Otherwise the parse routine has to be called. Filename parameter can be omitted, it defaults to /var/log/dpkg.log. Optionally its possible to specify from or to arguments as timestamps in the standard dpkg.log format or as DateTime objects. This will limit the entries which will be stored in the object to entries in the given timerange. Note that, if this is not what you want, you may ommit these attributes and can use filter_by_time() instead. By default the module will assume that those timestamps are in the local timezone as determined by DateTime::TimeZone. This can be overridden by giving the argument time_zone which takes a timezone string (e.g. 'Europe/Berlin') or a DateTime::TimeZone object. Additionally its possible to override the timestamp_pattern by specifying timestamp_format. This has to be a valid pattern for DateTime::Format::Strptime. $dpkg_log->filename $dpkg_log->filename('newfilename.log') Get or set the filename of the dpkg logfile. $dpkg_log->parse $dpkg_log->parse('time_zone' => 'Europe/Berlin') $dpkg_log->parse('time_zone' => $dt_tz ) Call the parser. The time_zone parameter is optional and specifies in which time zone the dpkg log timestamps are. If its omitted it will use the default local time zone. Its possible to specify either a DateTime::TimeZone object or a string. @entries = $dpkg_log->entries; @entries = $dpkg_log->entries('from' => '2010-01-01.10:00:00', to => '2010-01-02 24:00:00') Return all entries or all entries in a given timerange. from and to are optional arguments, specifying a date before (from) and after (to) which entries aren't returned. If only to is specified all entries from the beginning of the log are read. If only from is specified all entries till the end of the log are read. $entry = $dpkg_log->next_entry; Return the next entry. @entries = $dpkg_log->filter_by_time(from => ts, to => ts) @entries = $dpkg_log->filter_by_time(from => ts) @entries = $dpkg_log->filter_by_time(to => ts) @entries = $dpkg_log->filter_by_time(from => ts, to => ts, entry_ref => $entry_ref) Filter entries by given from - to range. See the explanations for the new sub for the arguments. If entry_ref is given and an array reference its used instead of $self->{entries} as input source for the entries which are to be filtered. ($from, $to) = $dpkg_log->get_datetime_info() Returns the from and to timestamps of the logfile or (if from/to values are set) the values set during object initialisation. SEE ALSO
DPKG::Log::Entry, DateTime, DateTime::TimeZone AUTHOR
Patrick Schoenfeld <schoenfeld@debian.org>. COPYRIGHT AND LICENSE
Copyright (C) 2011 Patrick Schoenfeld <schoenfeld@debian.org> This library is free software. You can redistribute it and/or modify it under the same terms as perl itself. perl v5.10.1 2011-02-26 DPKG::Log(3pm)
All times are GMT -4. The time now is 06:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy