linux ls命令按照时间文件大小排序

本文介绍了如何在Linux中使用ls命令,包括按时间(-lt)进行最新修改文件的展示,按文件大小(-lhS)排序,并使用-h参数以更易读的方式显示大小。涉及的示例和常用参数如prelink.cache、sysconfig等也被详细说明。
摘要由CSDN通过智能技术生成

通过修改时间列出,比较新的会在前面,使用-t参数

root@howtouselinux etc# ls -lt

参考: how to sort by time in Linux ls command
total 1680

-rw-r–r–. 1 root root 152927 Dec 8 03:14 prelink.cache

-rw-r–r–. 1 root root 264 Dec 7 23:31 mtab

-rw-r–r–. 2 root root 53 Dec 7 23:31 resolv.conf

-rw-r–r–. 1 root root 46 Dec 7 23:31 adjtime

drwxr-xr-x. 7 root root 4096 Dec 7 23:29 sysconfig

-rw-r–r–. 2 root root 165 Dec 7 23:28 hosts

-rw-r–r–. 1 root root 1 Dec 7 23:23 resolv.conf.save

排序文件大小,-S参数

参考:how to sort by size in Linux ls command

root@howtouselinux tmp# ls -lhS /etc/

total 1.7M

-rw-r–r–. 1 root root 626K Oct 2 2013 services

-rw-r–r–. 1 root root 150K Dec 8 03:14 prelink.cache

-rw-r–r–. 1 root root 87K Dec 7 14:44 termcap

-rw-r–r–. 1 root root 43K Sep 23 2011 mime.types

drwxr-xr-x. 3 root root 4.0K Dec 7 14:43 abrt

drwxr-xr-x. 4 root root 4.0K Dec 7 14:44 acpi

Linux ls command sort by size

显示文件大小

以便于人阅读的方式显示文件大小,-h参数

root@howtouselinux tmp# ls -lh

total 20K

drwxr-xr-x. 2 root root 4.0K Dec 8 00:44 1d

drwxr-xr-x. 2 root root 4.0K Dec 8 00:44 2d

drwxr-xr-x. 2 root root 4.0K Dec 8 00:44 3d

drwxr-xr-x. 2 root root 4.0K Dec 8 00:44 4d

drwxr-xr-x. 6 root root 4.0K Dec 8 00:46 TEST

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值