I have a list of files in teh following format and i wish to delete all files that are older than the latest .bac file not including the file with the same name as the .bac file or any other .bac files. A sample of teh files are bellow. I wish to dleet everything apart from 000000010000000300000067.00000020.bac ,000000010000000300000067 and files created after 000000010000000300000067.00000020.bac .Any ideas how to do this in perl

rw------- 1 postgres postgres 16777216 Jul 16 22:56 00000001000000030 +000005B -rw------- 1 postgres postgres 16777216 Jul 16 22:59 0000000100000003 +0000005C -rw------- 1 postgres postgres 16777216 Jul 16 23:01 0000000100000003 +0000005D -rw------- 1 postgres postgres 16777216 Jul 16 23:04 0000000100000003 +0000005E -rw------- 1 postgres postgres 16777216 Jul 16 23:06 0000000100000003 +0000005F -rw------- 1 postgres postgres 16777216 Jul 16 23:09 0000000100000003 +00000060 -rw------- 1 postgres postgres 16777216 Jul 16 23:12 0000000100000003 +00000061 -rw------- 1 postgres postgres 16777216 Jul 16 23:14 0000000100000003 +00000062 -rw------- 1 postgres postgres 16777216 Jul 16 23:17 0000000100000003 +00000063 -rw------- 1 postgres postgres 16777216 Jul 16 23:20 0000000100000003 +00000064 -rw------- 1 postgres postgres 16777216 Jul 16 23:23 0000000100000003 +00000065 -rw------- 1 postgres postgres 16777216 Jul 16 23:25 0000000100000003 +00000066 -rw------- 1 postgres postgres 16777216 Jul 16 23:26 0000000100000003 +00000067 -rw------- 1 postgres postgres 285 Jul 16 23:26 0000000100000003 +00000067.00000020.bac -rw------- 1 postgres postgres 16777216 Jul 16 23:27 0000000100000003 +00000068 -rw------- 1 postgres postgres 16777216 Jul 16 23:30 0000000100000003 +00000069

In reply to removing files with perl based on age and name by Jocqui

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.