Linux

Guide to Sort Files by Date Using LS Commandline in Linux

[ad_1]

The ls command is used to list directory contents and the results can be sorted upon several criteria such as by date, alphabetical order of filenames, modification time, access time, version and file size.

In this article, I will show you how to sort files by date using ls command in Linux.

1) List Files directory with Last Modified Date/Time

To list files and shows the last modified files at top, we will use -lt options with ls command.

2) List Files with Last Modified Date/Time (most recent at bottom)

We will use -ltr options with ls command to list files of a specific directory with recently modified files at the bottom.

If you want to sort by directory, then by dates use

3) Display in Human Readable format

We will use -halt options with ls command to list files of a specific directory in human readable file sizes, long format. It uses K, M, G, and T suffixes (or no suffix for bytes)

4) Find files modified in Last 10 minutes

We can get files modified in last 10 minutes with command below:

5) Recently modified 10 files

Let see how to check recently modified 10 files in a directory using ls commands. We will use a combination of ‘ls” and ‘head’ command.

Below command will show modified 10 files with the recently updated file at the top

Or

with tail combination, it shows recently updated file at the bottom.

Thanks for reading this article and please comment below if you find any other options useful.

Read Also:

[ad_2]

Facebook Comments

Show More

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button