#!/usr/bin/perl use Date::Manip; $ndays=$ARGV[0]; # Get the logs $date = ParseDate("$ndays days ago"); print UnixDate($date,"%m/%d/%Y") . "\n";
In the input file, the values are of 3 day and 2 day old date. I have to extract the time from Suppose date is : Thu Jul 8 2010 This is the inout file,
- [5/Jul/2010:00:59:59 +0000] - [5/Jul/2010:00:10:00 +0000] - [5/Jul/2010:06:10:00 +0000] - [5/Jul/2010:06:50:00 +0000] - [5/Jul/2010:07:10:00 +0000] - [5/Jul/2010:10:10:00 +0000] - [6/Jul/2010:06:10:00 +0000] - [6/Jul/2010:07:10:00 +0000] - [5/Jul/2010:08:10:00 +0000] - [5/Jul/2010:06:10:00 +0000] - [5/Jul/2010:09:10:00 +0000] - [5/Jul/2010:10:00:00 +0000] - [5/Jul/2010:10:15:00 +0000]
Extract the rows, where time is greater than 5/Jul/2010:06:00:00 and less than 6/Jul/2010:10:00:00 So the expected output is :
- [5/Jul/2010:06:10:00 +0000] - [5/Jul/2010:06:50:00 +0000] - [5/Jul/2010:07:10:00 +0000] - [5/Jul/2010:10:10:00 +0000] - [6/Jul/2010:06:10:00 +0000] - [6/Jul/2010:07:10:00 +0000] - [5/Jul/2010:08:10:00 +0000] - [5/Jul/2010:06:10:00 +0000] - [5/Jul/2010:09:10:00 +0000] - [5/Jul/2010:10:00:00 +0000]

In reply to Re^2: Extract the lines from file by Anonymous Monk
in thread Extract the lines from file by Anonymous Monk

Title:
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, details, 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, summary, 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.