This article presents a detailed guide to sort file using “ls” by the last changed date in Debian.
Debian | Sort “ls” by Last Changed Date
Be default, the “ls” command displays the file list in alphabetical order as shown below:
If you use “-t” parameter with the ls command, it sorts the files list with the time period. The -t stands for time modified and it sorts the files that are recently changed. The general command for sorting the files in which the last changes are made at the top is the following:
If you use the -lht with the “ls” command, it sorts the list based on last modified human-readable files in the current directory:
The below command is used for sorting the recently changed files at the bottom in the current directory:
To sort the list with the last modified date and time, you can use the -lt parameter with the ls command as shown below:
If you want to sort the list in reverse order with the perspective of the day and time, use the following command in the terminal:
Bottom Line
The ls command is used to display the files and directories at the current location in the terminal. By default, it displays the list in alphabetical order. By using several flags or parameters with “ls” commands, you can sort files in last changed date order in Debian.