Linux ls sequencing

Source: Internet
Author: User

To view files in Linux, sometimes you need to sort the files.

For example, the WebLogic, Oracle directory, is not sorted by creation time or file size by default.

[Email protected] oracle]$ ls-l
Total 184
Drwxr-xr-x 6 web WebLogic 4096 07-02 09:19 coherence_3.7
-RW-RW----1 Web weblogic 426 07-02 09:29 domain-registry.xml
Drwxr-xr-x 2 web weblogic 4096 07-11 11:12 logs
Drwxr-xr-x 7 web WebLogic 36864 07-02 09:16 Modules
-rw-r--r--1 Web weblogic 849 07-02 09:19 OCM.RSP
-rw-r--r--1 Web weblogic 108849 07-02 09:19 registry.dat
-rw-r--r--2 Web weblogic 1908 07-02 09:19 registry.xml
-rw-r--r--1 Web weblogic 1908 07-11 11:10 registry.xml--
Drwxr-x---3 web weblogic 4096 07-02 09:24 user_projects
Drwxr-xr-x 8 web WebLogic 4096 07-02 09:18 utils
Drwxr-xr-x 8 web WebLogic 4096 07-02 09:19 wlserver_10.3

1, by the creation time to sort, defaults to the time most recent pre-row

[Email protected] oracle]$ LS-LT
Total 184
Drwxr-xr-x 2 web weblogic 4096 07-11 11:12 logs
-rw-r--r--1 Web weblogic 1908 07-11 11:10 registry.xml--
-RW-RW----1 Web weblogic 426 07-02 09:29 domain-registry.xml
Drwxr-x---3 web weblogic 4096 07-02 09:24 user_projects
Drwxr-xr-x 6 web WebLogic 4096 07-02 09:19 coherence_3.7
Drwxr-xr-x 8 web WebLogic 4096 07-02 09:19 wlserver_10.3
-rw-r--r--2 Web weblogic 1908 07-02 09:19 registry.xml
-rw-r--r--1 Web weblogic 108849 07-02 09:19 registry.dat
-rw-r--r--1 Web weblogic 849 07-02 09:19 OCM.RSP
Drwxr-xr-x 8 web WebLogic 4096 07-02 09:18 utils
Drwxr-xr-x 7 web WebLogic 36864 07-02 09:16 Modules

2, sorted by file size, note that the parameter is uppercase S, the default is the largest file row before

[Email protected] oracle]$ Ls-ls
Total 184
-rw-r--r--1 Web weblogic 108849 07-02 09:19 registry.dat
Drwxr-xr-x 7 web WebLogic 36864 07-02 09:16 Modules
Drwxr-xr-x 6 web WebLogic 4096 07-02 09:19 coherence_3.7
Drwxr-xr-x 2 web weblogic 4096 07-11 11:12 logs
Drwxr-x---3 web weblogic 4096 07-02 09:24 user_projects
Drwxr-xr-x 8 web WebLogic 4096 07-02 09:18 utils
Drwxr-xr-x 8 web WebLogic 4096 07-02 09:19 wlserver_10.3
-rw-r--r--2 Web weblogic 1908 07-02 09:19 registry.xml
-rw-r--r--1 Web weblogic 1908 07-11 11:10 registry.xml--
-rw-r--r--1 Web weblogic 849 07-02 09:19 OCM.RSP
-RW-RW----1 Web weblogic 426 07-02 09:29 domain-registry.xml

The 5th column is the file size and the largest file is Registry.dat.

3, reverse order (inverted row), using the-R parameter

[Email protected] oracle]$ LS-LSR
Total 184
-RW-RW----1 Web weblogic 426 07-02 09:29 domain-registry.xml
-rw-r--r--1 Web weblogic 849 07-02 09:19 OCM.RSP
-rw-r--r--1 Web weblogic 1908 07-11 11:10 registry.xml--
-rw-r--r--2 Web weblogic 1908 07-02 09:19 registry.xml
Drwxr-xr-x 8 web WebLogic 4096 07-02 09:19 wlserver_10.3
Drwxr-xr-x 8 web WebLogic 4096 07-02 09:18 utils
Drwxr-x---3 web weblogic 4096 07-02 09:24 user_projects
Drwxr-xr-x 2 web weblogic 4096 07-11 11:12 logs
Drwxr-xr-x 6 web WebLogic 4096 07-02 09:19 coherence_3.7
Drwxr-xr-x 7 web WebLogic 36864 07-02 09:16 Modules
-rw-r--r--1 Web weblogic 108849 07-02 09:19 registry.dat


Note: The 2nd column means the number of hard links or directories , the number of hard links to the file, and the number of subdirectories for the folder.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.