Search code examples
bashshellunixglob

Faster iteration over thousands of files


I'm trying to do something on ~200,000 files in a single folder.

When I do this:

for i in *; do /bin/echo -n "."; done

One dot is printed every few seconds. The same operation on a folder with a hundred files works blazingly fast.

Why is this so? How to accelerate the process for folders with thousands of files?


Solution

  • Try this with GNU find:

    find . -maxdepth 1 -type f -printf "."