for(<*>){((stat)[9]<(unlink))}

The apparently useless stat and < made me a bit curious, so I googled it a bit. There are several places where the above is presented as a one-liner for "fast file deletion", but without explaining what the stat might be for.

Several people claimed that the Perl solution is faster than find with the -delete option, and I found one (possibly dubious) claim that it's because find uses fstatat64 syscalls while Perl uses lstat64+stat64 syscalls (a quick check on my system appears to confirm this). However, since it isn't my area of expertise, I'm not sure if that causes a speed difference.

In a post by Kent Fredric - https://www.quora.com/Linux-why-stat+unlink-can-be-faster-than-a-single-unlink - he shows that removing the stat actually gives a minor performance improvement, so I suspect it really isn't necessary.

My best guess for now is that the code snippet is a bastardization of something like this, and it's just been cargo-culted from there.


In reply to Re: Onliner magic to remove files by Anonymous Monk
in thread Onliner magic to remove files by glasswalk3r

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.