Sponsored Content
Top Forums Shell Programming and Scripting [Perl] Same entries in file, but treat them different. Post 302521660 by ejdv on Thursday 12th of May 2011 02:19:17 AM
Old 05-12-2011
Thanks.
I always envy persons that can produce a one-liner for something where I need a full page.

Quote:
Originally Posted by mirni
What exactly is your problem?
My problem is that the line with "Starting Table table loading" appears 3 times and that always the last entry is taken for calculation.
So I got 3 times the same start time for 3 different events.

And the problem with this example is that I took out some lines for simplicity.
But you got my intentions right.

What if the log.out file is something like this:

Quote:
table_load,1304943291,Mon May 9 12:14:51 GMT 2011,STATUS: Blah blah blah.
table_load,1304943291,Mon May 9 12:14:51 GMT 2011,STATUS: Sorting of Table data file started.
table_load,1304943291,Mon May 9 12:14:51 GMT 2011,STATUS: Blah blah blah.
table_load,1304943291,Mon May 9 12:14:51 GMT 2011,STATUS: Blah blah blah.
table_load,1304943750,Mon May 9 12:22:30 GMT 2011,STATUS: Starting Table table loading.
table_load,1304943291,Mon May 9 12:14:51 GMT 2011,STATUS: Blah blah blah.
table_load,1304943291,Mon May 9 12:14:51 GMT 2011,STATUS: Blah blah blah.
table_load,1304943291,Mon May 9 12:14:51 GMT 2011,STATUS: Blah blah blah.
table_load,1304947100,Mon May 9 13:18:20 GMT 2011,STATUS: Sorting of Table1 data file started.
table_load,1304943291,Mon May 9 12:14:51 GMT 2011,STATUS: Blah blah blah.
table_load,1304947546,Mon May 9 13:25:46 GMT 2011,STATUS: Starting Table table loading.
table_load,1304943291,Mon May 9 12:14:51 GMT 2011,STATUS: Blah blah blah.
table_load,1304943291,Mon May 9 12:14:51 GMT 2011,STATUS: Blah blah blah.
table_load,1304950974,Mon May 9 14:22:54 GMT 2011,STATUS: Sorting of Table2 data file started.
table_load,1304943291,Mon May 9 12:14:51 GMT 2011,STATUS: Blah blah blah.
table_load,1304943291,Mon May 9 12:14:51 GMT 2011,STATUS: Blah blah blah.
table_load,1304943291,Mon May 9 12:14:51 GMT 2011,STATUS: Blah blah blah.
table_load,1304951297,Mon May 9 14:28:17 GMT 2011,STATUS: Starting Table table loading.
table_load,1304943291,Mon May 9 12:14:51 GMT 2011,STATUS: Blah blah blah.
table_load,1304954040,Mon May 9 15:14:00 GMT 2011,STATUS: Creating Table indexes.
table_load,1304943291,Mon May 9 12:14:51 GMT 2011,STATUS: Blah blah blah.
table_load,1304943291,Mon May 9 12:14:51 GMT 2011,STATUS: Blah blah blah.
table_load,1304956993,Mon May 9 16:03:13 GMT 2011,STATUS: Analyzing table Table.
table_load,1304943291,Mon May 9 12:14:51 GMT 2011,STATUS: Blah blah blah.
table_load,1304957476,Mon May 9 16:11:16 GMT 2011,STATUS: End of table_load.
Probably I need to write the lines I need to an array and use your code.
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk - treat multiple delimiters as one

Is there anyway to get awk to treat multiple delimiters as one? Particularly spaces... (6 Replies)
Discussion started by: peter.herlihy
6 Replies

2. Shell Programming and Scripting

How to get the difference between dates?Can i treat as string?

Hi All , I have an output value with two columns like this... Days User 10 A 500 B 1 C How i can compare the first column value and passing the user name as parameter? For example : while read -r days If (days<=30) ; then value=days/30 x100 ... (3 Replies)
Discussion started by: EDBGSK
3 Replies

3. Shell Programming and Scripting

while read loop w/ a nested if statement - doesn't treat each entry individually

Hi - Trying to take a list of ldap suffixes in a file, run an ldapsearch command on them, then run a grep command to see if it's a match, if not, then flag that and send an email alert. The list file (ldaplist) would look like - *********** o=company a o=company b *********** **... (7 Replies)
Discussion started by: littlefrog
7 Replies

4. UNIX for Dummies Questions & Answers

make script treat * as a regular character

I need a script that reads the out put of a command (softwareupdate --list) and will tally up the number of asterisks in the output and tell me how many there were. How do I go about getting my script to treat asterisks as a regular character and not a wildcard or some other operator? (8 Replies)
Discussion started by: glev2005
8 Replies

5. UNIX for Dummies Questions & Answers

doubt to treat plaintext script

Hi everyone! first of all thank you all for the forum. My question is, is there a bash or java program, which addresses the existing text in the html that is visible in the web page for editing by another string, eg name1: flakjsdlñfjas Name of father: fdfjaksdfjskdfsd Well it... (1 Reply)
Discussion started by: xavilito
1 Replies

6. Shell Programming and Scripting

Perl's buffered I/O is causing me to miss latest log file entries in log colorizer. How to fix?

I've been finding myself using a log file colorizer written in perl to reformat and colorize the output from many different programs. Mainly, however, I use it to make the output from "tail -f" commands more readable. The base perl script I use is based on "colorlogs.pl" available from the... (1 Reply)
Discussion started by: rcsteiner
1 Replies

7. Shell Programming and Scripting

awk script modification - treat certain files differently

awk 'BEGIN{OFS=","} FNR == 1 {if (NR > 1) {print fn,fnr,nl} fn=FILENAME; fnr = 1; nl = 0} {fnr = FNR} /UNUSUAL/ && /\.gz/ ~ /FILENAME/ {nl++} <'{system ("gunzip -cd FILENAME")}' END ... (2 Replies)
Discussion started by: SkySmart
2 Replies

8. Shell Programming and Scripting

Treat Command Output as a File

Hi. Before I've post this question, I have spent hours looking for the solutions but to no avail. Because I think it is possible but I just don't know what is the right keyword to search for. Ok, basically what I want to achieve is really simple. It's just that I don't want to write... (20 Replies)
Discussion started by: aimy
20 Replies
Time::Duration::Parse(3pm)				User Contributed Perl Documentation				Time::Duration::Parse(3pm)

NAME
Time::Duration::Parse - Parse string that represents time duration SYNOPSIS
use Time::Duration::Parse; my $seconds = parse_duration("2 minutes and 3 seconds"); # 123 DESCRIPTION
Time::Duration::Parse is a module to parse human readable duration strings like 2 minutes and 3 seconds to seconds. It does the opposite of duration_exact function in Time::Duration and is roundtrip safe. So, the following is always true. use Time::Duration::Parse; use Time::Duration; my $seconds = int rand 100000; is( parse_duration(duration_exact($seconds)), $seconds ); FUNCTIONS
parse_duration $seconds = parse_duration($string); Parses duration string and returns seconds. When it encounters an error in a given string, it dies an exception saying "Unknown timespec: blah blah blah". This function is exported by default. AUTHOR
Tatsuhiko Miyagawa <miyagawa@bulknews.net> COPYRIGHT
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Some internal code is taken from Cache and Cache::Cache modules on CPAN. SEE ALSO
Date::Manip, DateTime::Format::Duration, <http://use.perl.org/~miyagawa/journal/30310> perl v5.10.0 2008-06-02 Time::Duration::Parse(3pm)
All times are GMT -4. The time now is 09:30 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy