Ls display sorting

Source: Internet
Author: User

When ls displays the contents of a directory, the file is displayed in alphabetical order from a to z. The priority is as follows;

Number
A-z
A-Z

That is to say, if you do not add any sort parameters, the first letter of the file name is a number, will give priority to display; second is the A-Z, then is a-z; below is a few sort parameters, you will know after a few exercises;

The-S parameter is used for sorting the file size;
For reverse sorting, we need to use the-r parameter;
The-t parameter is used for sorting by the last access;
Sort by extension. The-X parameter is used;

Example

[root@localhost ~]# ls
123.txt          fonts.scale         kernel                           myinstall.log  upgrade.log
anaconda-ks.cfg  install.log.syslog  mkuml-2004.07.17-ananas.tar.bz2  plinux.txt     upgrade.log.syslog
[Root @ localhost ~] # Ls-lS/root
[Root @ localhost ~] # Ls-lS
Total 180
-Rw-r -- 1 root 68012 04-04 mkuml-2004.07.17-ananas.tar.bz2
-Rw-r -- 1 root 53992 03-16 08:54 myinstall. log

Example:

[Root @ localhost ~] # Ls-lr
Total 180
-Rw-r -- 1 root 0 03-26 18:39 upgrade. log. syslog
-Rw-r -- 1 root 613 03-26 18:41 upgrade. log
-Rw-r -- 1 root 0 04-19 14:10 plinux.txt

[Root @ localhost ~] # Ls-lt
Total 180
Drwxr-xr-x 2 root 4096 04-19 20:04 kernel
-Rw-r -- 1 root 21 04-19 :06 123.txt
-Rw ------- 1 root 1375 04-19 anaconda-ks.cfg
-Rw-r -- 1 root 0 04-19 14:10 plinux.txt

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.