zoukankan      html  css  js  c++  java
  • linux ls命令的重要用法:按照文件大小排序和按照时间排序

    1.ls命令是list的缩写,用来打印当前目录清单或者打印出指定目录下的文件及文件清单。

    2.本文介绍ls的重要用法:按“文件大小”排序列出文件清单和按“时间”排序列出文件清单。

    3.按“文件大小”排序列出文件清单。

    #-S 以文件的大小进行降序排序
    [root@node5 ~]# ls -alSh /root/
    total 1.4G
    -rw-r--r--   1 root root 802M Aug  4 09:06 linux-4.19.77.tar
    -rw-r--r--   1 root root 393M Aug  4 09:06 qemu-4.1.0.tar
    -rw-r--r--   1 root root 183M May  2  2019 jdk-8u172-linux-x64.tar.gz
    -rw-r--r--   1 root root 9.6M Aug  4 09:05 glibc-aarch64-linux-gnu-2.24-2.sdl7.2.noarch.rpm
    ......
    
    #-S 以文件的大小进行升序排序
    [root@node5 opt]# ls -lSrh
    total 136K
    drwxr-xr-x  3 root root  19 Nov  3 16:21 usr
    drwxr-xr-x 11 root root 151 Apr 22  2020 nginx
    drwxr-xr-x 10 root root 174 May  7  2019 apache-tomcat-8.0.51
    -rw-r--r--  1 root root 22K Oct  9 16:48 xfsdump_shadow
    -rw-r--r--  1 root root 23K Oct 10 01:09 sdb6_incredump2
    -rw-r--r--  1 root root 23K Oct 10 01:06 sdb6_incredump1
    -rw-r--r--  1 root root 24K Oct  9 16:41 xfsdump_sdb6
    -rw-r--r--  1 root root 45K Oct 10 01:02 sdb6_fulldump
    

    4.按“时间”排序列出文件清单。

    #-t 按时间排序,-r从小到大,不加r由大到小
    #-r是reverse的简写,表示反转
    [root@node5 opt]# ls -ltr
    total 136
    drwxr-xr-x 10 root root   174 May  7  2019 apache-tomcat-8.0.51
    drwxr-xr-x 11 root root   151 Apr 22  2020 nginx
    -rw-r--r--  1 root root 23944 Oct  9 16:41 xfsdump_sdb6
    -rw-r--r--  1 root root 22416 Oct  9 16:48 xfsdump_shadow
    -rw-r--r--  1 root root 46048 Oct 10 01:02 sdb6_fulldump
    -rw-r--r--  1 root root 23504 Oct 10 01:06 sdb6_incredump1
    -rw-r--r--  1 root root 23280 Oct 10 01:09 sdb6_incredump2
    drwxr-xr-x  3 root root    19 Nov  3 16:21 usr
    
    [root@node5 opt]# ls -ltrh
    total 136K
    drwxr-xr-x 10 root root 174 May  7  2019 apache-tomcat-8.0.51
    drwxr-xr-x 11 root root 151 Apr 22  2020 nginx
    -rw-r--r--  1 root root 24K Oct  9 16:41 xfsdump_sdb6
    -rw-r--r--  1 root root 22K Oct  9 16:48 xfsdump_shadow
    -rw-r--r--  1 root root 45K Oct 10 01:02 sdb6_fulldump
    -rw-r--r--  1 root root 23K Oct 10 01:06 sdb6_incredump1
    -rw-r--r--  1 root root 23K Oct 10 01:09 sdb6_incredump2
    drwxr-xr-x  3 root root  19 Nov  3 16:21 usr
    
  • 相关阅读:
    017-新闻表分页增删改查
    016-页面生命周期
    015-用户登录注册
    014-Session服务器状态保持
    013-Cookie状态保持
    012-ViewState状态保持
    011-Server服务器对象属性
    010-判断是否回传IsPostBack属性
    Github使用教程
    获取中文时间
  • 原文地址:https://www.cnblogs.com/renshengdezheli/p/13927272.html
Copyright © 2011-2022 走看看