ls顯示排序__擴充

來源:互聯網
上載者:User

ls 顯示目錄的內容時,會將檔案按a到z的字母順序顯示,優先順序如下; 數字
a-z
A-Z

也就是說如果不加任何排序的參數,檔案名稱第一個字母是數位,將優先顯示;其次才是A-Z,然後才是a-z;下面是幾個排序的參數,大家練習一下就知道了; 在檔案的大小排序上,我們要用到-S參數;
如果是逆序排序時,我們要用到-r參數;
按最後訪問的時候排序,要用到-t參數;
根據副檔名進行排序,要用到參數 -X ;

舉例 [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
總計 180
-rw-r--r-- 1 root root 68012 04-04 20:28 mkuml-2004.07.17-ananas.tar.bz2
-rw-r--r-- 1 root root 53992 03-16 08:54 myinstall.log

舉例: [root@localhost ~]# ls -lr
總計 180
-rw-r--r-- 1 root root     0 03-26 18:39 upgrade.log.syslog
-rw-r--r-- 1 root root   613 03-26 18:41 upgrade.log
-rw-r--r-- 1 root root     0 04-19 14:10 plinux.txt

[root@localhost ~]# ls -lt
總計 180
drwxr-xr-x 2 root root  4096 04-19 20:04 kernel
-rw-r--r-- 1 root root    21 04-19 15:06 123.txt
-rw------- 1 root root  1375 04-19 15:04 anaconda-ks.cfg
-rw-r--r-- 1 root root     0 04-19 14:10 plinux.txt

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.