I think I figured out how to a2p
#!perl
eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
if $running_under_some_shell;
# this emulates #! processing on NIH machines.
# (remove #! line above if indigestible)
eval '$'.$1.'$2;' while $ARGV[0] =~ /^([A-Za-z_0-9]+=)(.*)/ && shift;
# process any FOO=bar switches
while (<>) {
@Fld = split(' ', $_, -1);
$tm = $Fld[(1)-1] . ' ' . $Fld[(2)-1] . ' ' . $Fld[(3)-1];
;
print $_ if $start lt $tm && $tm lt $end; #??? #???
}
Please check my work on the 2 lines I've marked with "#???".
The operation I've selected may be wrong for the operand types.
Massaging that a little and adding start/end
#!/usr/bin/perl --
use strict; use warnings; use Data::Dump;
my $start = qx{date +'%b %e %T'};
my $end = qx{date -d '10 mins ago' +'%b %e %T'};
dd $start, $end;
while (<>) {
my @Fld = split(' ', $_, -1);
my $tm = $Fld[(1)-1] . ' ' . $Fld[(2)-1] . ' ' . $Fld[(3)-1];
print $_ if $start lt $tm and $tm lt $end;
}
Use as ./tminus10 path/to/logfile
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|