Get the App
SLTechnology News&Howtos  ›  Servers  › 

Linux Tip: ls-l-View file information, sorted by time and size

Shulou Source: shulou.com Published: 2022-06-02 19:44:39 10月02日 Update

First, sort by time:

Ascending order is the arrangement of data from low to high, and descending order is the arrangement of data from high to low

Ls in descending chronological order: ls-lt (most commonly used)

Ls in ascending chronological order: ls-lrt

View files by file modification time:

Plus-r is the reverse sort:

The command explains:

-t: sort by modification time. In fact, we can use the man ls command to see the use of the parameters with the ls command.-t sort by modification time,newest first sorts files by modification time. The default is the most recently modified first.

-r: reverse sort, reverse order

Example: ls-ltr: sort in reverse by modification time [that is, the latest modification time comes last]

Sort by file size:

Plus-h displays the file size with units:

The command explains:

Ls-lS is sorted from largest to smallest

Ls-Slr is sorted from small to large

Ls lSh | ls-lShr if you want to type in a "human-readable way", add a-h to indicate "--human-readable"

In this way, the unit is k or M, and it is easier to see the results clearly.

Tags: Sort time file command size ascending order unit data interpretation from small to large human from small example reverse parameter that is commonly used mode result input Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn MariaDB NVidia Apple Huawei