in reply to Re: using Linux getdents syscall
in thread using Linux getdents syscall

I don't care about portability or be POSIX conform... I need to erase lots of files the faster (and with low overhead) as possible in Linux.

readdir works fine, but when the directory starts having thousands of files performance starts slowing down.

It just occurred to me right now that I could check if readdir does a stat system call in each file inside the directory... that would explain why Perl code to clean the directory is slower. But wouldn't help me solve this issue anyway.

Alceu Rodrigues de Freitas Junior
---------------------------------
"You have enemies? Good. That means you've stood up for something, sometime in your life." - Sir Winston Churchill

Replies are listed 'Best First'.
Re^3: using Linux getdents syscall
by KurtSchwind (Chaplain) on Nov 24, 2015 at 19:19 UTC

    There has already been lots of great input on this topic. I'll add that there is no faster way on a *nix box to delete a large number of files from a directory than using xargs.

    Either with:  ls [SOME MASK] |xargs rm

    or ls |grep [SOME MASK] |xargs rm

    --
    “For the Present is the point at which time touches eternity.” - CS Lewis