更快地迭代数千个文件

时间:2022-01-17 18:54:20

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

我正在尝试在单个文件夹中的~200,000个文件上做一些事情。

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?

为什么会这样?如何加速包含数千个文件的文件夹的过程?

1 个解决方案

#1


Try this with GNU find:

尝试使用GNU find:

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

#1


Try this with GNU find:

尝试使用GNU find:

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

相关文章