Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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

In reply to Re^3: grep lines from log for last 10 mints by Anonymous Monk
in thread grep lines from log for last 10 mints by bimleshsharma

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the voices are still...

    How do I use this? | Other CB clients
    Other Users?
    Others imbibing at the Monastery: (4)
    As of 2018-05-27 00:16 GMT
    Find Nodes?
      Voting Booth?