I have a directory with tens of thousands of files. I want to list the most recently modified files (for example files modified within the last day or whatever).
The following command works but is slow because it has to ls
every file in the folder:
ls -rt | tail -n 10
The following command is faster but the output is not as detailed as ls
:
find -mtime -1
Is there a way I can list the most recently modified files (either a set number or by date) with ls
-like output but faster?
bash
tag, as I didn't see anything bash-specific in your question. Different shells have different capabilities, so if bash is a hard requirement, please make that clear in the body of the question (along with the tag). Otherwise, shell would be appropriate.