Sunday, August 29, 2021

Show HN: Get lists of files in a directory that contains a large number of files

lls

lls is lightweight ls. Using lls, you can get a list of files in a directory that contains a large number of files.

How?

You allocate a buffer for the size of the directory, and then call the getdents64 system call directly.

The larger the size of the directory, the more memory you will need. By running ls -dl, you will know how much memory to allocate in advance.

See this article for more information.

Usage

$ lls > output.txt

$ lls / > output.txt

If you want to reduce the memory usage, you can specify the -buf-size option. If the size you specify is smaller than the actual size needed, you will not get the full file list.



from Hacker News https://ift.tt/3DtRscM

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.