231 ms·
did you try ls -1? in the far past I had the same problem listing millions of files in a dir edit: if I remember correctly ls bufferizes the results for sorti
by mercurialuser 5y ago
did you try ls -1?
in the far past I had the same problem listing millions of files in a dir
edit: if I remember correctly ls
bufferizes the results for sorting. with -1 it just dumps the values
- acdha 5y agoIt’s not “ls -1” but “--sort=none” or “-U”.
- loeg 5y ago"ls -f" in POSIX ls (which GNU ls also implements). Also, avoid "-F", which will stat each file.
- the_arun 5y ago`ls | more` works too, right?
- loeg 5y agoAt least with GNU ls, 'ls | more' does not disable sorting. It disables automatic color (which is important -- coloring requires 'stat(2)'ing every file in the directory).
- acdha 5y agoNo - it still does all of the work to sort the entries, which is the slow part since it prevents the first entry from being displayed until the last has been retrieved.
- innagadadavida 5y agoI think it also tries to nearly format into columns and this requires it to know name lengths for all files. If you do -l it basically outputs one file per line and can be done more efficiently.
- antegamisou 5y agofind . would be another alternative