linux ls命令的重要用法:按照文件大小排序和按照时间排序
2023-02-18 16:34:24 时间
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
相关文章
- PHP官方框架 Zend Framework 2.1 发布
- PHP 5.4 内置Web服务器使用说明
- 一个小巧的PHP防注入类
- PHPCMS后台入口地址隐藏方法
- 在Linux中将目录压缩打包为zip文件 并通过ftp上传的Shell脚本
- 用PHP解析XML为数组的方法
- 一段经典的抽奖算法 for PHP版
- 在Linux中用Shell脚本完成SVN版本库的建立
- PHPCMS V9无法正常通过QQ登录的解决方案
- 解决Nginx环境下PHP的flush失效问题
- 用SS5在Linux上搭建Socks5 Proxy代理服务器
- Linux中编译安装Redis和PHP扩展
- 通过iptables规则让Linux主机屏蔽Ping
- 在Linux中部署FFmpeg开源视频压缩环境过程简单笔记
- 采用单例模式编写PHP的PDO类
- Linux下管理Memcached的Service脚本
- 开源消息队列MemcacheQ在Linux中编译安装教程
- Linux下部署Memcached和PHP的Memcache扩展方法
- PHP利用FFmpeg读取视频播放时长和码率等信息
- 用PHP实现URL转换短网址的算法