The -t flag will command the ls command to exit for the last modified date and time, but for best results, you'll probably want to apply it with the long-list indicator "-l". Let's look at some useful ways to sort out "ls" by date.
Sort output 'ls' by dateThe -t flag will sort the output of the ls command by the last modification date and time:
Open Terminal, and scroll to the directory you want to sort by date with ls
Applies the following command syntax:
Ls -ltPress "Enter" to see the contents of the directory listed with ls by date
Show "ls" sorted by date, readability and others
If you want to reverse the order so that the most recently modified elements are at the bottom of the output of the ls command, you can add the -r flag:
Invert the output order by date with "ls"
Ls -haltrThe output will be the same except it is shown in reverse order, with the oldest modification date and time at the top and most recently at the bottom.