It might be faster, but it won't work for large directories.
For large directories, I either use 'ls --color=never' or the example C program in 'man 2 getdents'.
For large directories, I either use 'ls --color=never' or the example C program in 'man 2 getdents'.
ls -U huge_dir | awk 'NR % 100000 == 0 { print NR } END { print NR }'
(prints the count every 100k files and the total at the end).