How to extract the date that is of 3 days old

Dates don't age, so that makes no sense. My only guess as to what that means is "the date of 3 days ago", but that makes no sense in context. Please explain more clearly. Perhaps you could show what output expect from the data you showed?

Update: I think I got it. You want the lines from the 24 hours that end 3*24 hours ago.

Personally, I'd use a date-time format that lexically sorts in chronological order (e.g. 2010/07/06:07:00:10). Then you could precalculate the start and end timestamps, and use string comparisons. It's much faster to compare to strings than to parse a date plus compare two dates.

You're probably searching through the file linearly, which could require reading a lot of lines in which you have no interest, especially if the lines you want are near the end of the file. Since the entries in the files are sorted, you could do a binary search of the file with the help of seek. Then you'd only need to read 25 lines (log2(19739530)) to find the lines in which you are interested.


In reply to Re: Extract the lines from file by ikegami
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.