You can list a directory containing 8M files, but not with ls
If you are going to have a directory with millions of files, probably there's one more interesting thing to consider.<p>As you might know ext* and some other FSs store filenames right in the directory file. Means the more files you have in the directory, the bigger directory size gets. In majority of cases nothing unusual happens, cause people have maybe a few dozens of dirs / files.<p>However if you'll put millions of files, then directory size grows up to a few megabytes in size. If you decide to clean up later, you'd probably expect the directory size to shrink. But it never happens. Unless you run fsck or re-create a directory.<p>That's because nobody believes the implementation effort really worth it. Here's a link to lkml discussion: <a href="https://lkml.org/lkml/2009/5/15/146" rel="nofollow">https://lkml.org/lkml/2009/5/15/146</a><p>PS. Here's a previous discussion of the very same article posted in this submission. It's been 10 years already :) <a href="https://news.ycombinator.com/item?id=2888820" rel="nofollow">https://news.ycombinator.com/item?id=2888820</a><p>upd. Here's a code example:<p>$ mkdir niceDir && cd niceDir<p># this might take a few moments<p>$ for ((i=1;i<133700;i++)); do touch long_long_looong_man_sakeru_$i ; done<p>$ ls -lhd .<p>drwxr-xr-x 2 user user 8.1M Aug 2 13:37 .<p>$ find . -type f -delete<p>$ ls -l<p>total 0<p>$ ls -lhd .<p>drwxr-xr-x 2 user user 8.1M Aug  2 13:37 .