Linux / Unix: Sort ls Command Output By Last Modified Date and Time

Linux / Unix: Sort ls Command Output By Last Modified Date and Time

To sort the output of the ls command by the last modified date and time, you can use the -lt option. This option tells the ls command to sort the output by the last modified date and time, with the most recently modified files appearing first.

For example, to list the files in the current directory sorted by the last modified date and time, you can use the following command:

re‮ef‬r to:lautturi.com
ls -lt

If you want to display the last modified date and time in a human-readable format, you can use the -lh option instead:

ls -lh

You can also use the -t option by itself to sort the output by the last modified date and time, and the -h option by itself to display the file sizes in a human-readable format.

ls -t
ls -h

Keep in mind that these options are specific to the ls command on a Linux or Unix system. The options and syntax may be different on other operating systems.

Created Time:2017-10-29 22:08:59  Author:lautturi