How to list the ten most recent files in the same directory

From LemonWiki共筆
Jump to navigation Jump to search

How can I list the ten most recent files in a directory using the command line?

Windows[edit]

If you know the path to your target directory on Win Os windows.png , use:

dir path\to\working_folder /O-D

For paginated viewing:

dir path\to\working_folder /O-D | more

If you're already in the working folder:

dir . /O-D
dir . /O-D | more

Linux[edit]

If you know the path to your target directory on Linux Os linux.png or Mac icon_os_mac.png , use:

ls -lht /path/to/working_folder | head -10

If you're already in the working folder:

ls -lht . | head -10
ls -lht | head -10

References[edit]