lowmem-tools provides alternative implementations of ls and rm which can gracefully handle directories containing a very large number of files.