Site icon LinuxCommands.site

Sort files or folders by date/time with ls command in linux/unix

Linux ls sorted by date, which makes it easier for us to manage files and subdirectories, especially when there are many files or directories.

Linux ls -t option can be sorted by date from newest to oldest, or ls -rt option can be sorted by date from oldest to new.

# ls sort by date from newest to oldest
➜ ls -t

# ls sort by date from oldest to new
➜ ls -tr

However, you will find that although the above method can be sorted by date, it is not easy for us to view. At this time, we usually use it with ls -l option, which can display richer structured information.

➜  ls -lt


➜  ls -lrt

When the number of files and subdirectories in a directory is large, we recommend using the ls -rlt long format to sort by date, which will allow you to find newer files or directories faster.

Exit mobile version