创作背景:
在linux下查看目录文件所占大小
ls # 是查看目录下有哪些文件
ls -l # 查看文件大小,total总用量是以K为单位,单个文件是以B为单位
ls -lh # 查看文件大小,total总用量是以M为单位
ls -lht # 查看文件大小
[root@vm1 ~]# ls
t1.txt t2.txt t3.txt t4.txt t5.txt t6.txt t7.txt t8.txt t9.txt
[root@vm1 ~]# ls -l
total 1620
-rw-r--r-- 1 root root 182643 Apr 1 13:36 t1.txt
-rw-r--r-- 1 root root 182643 Apr 1 13:37 t2.txt
-rw-r--r-- 1 root root 182643 Apr 1 13:37 t3.txt
-rw-r--r-- 1 root root 182643 Apr 1 13:37 t4.txt
-rw-r--r-- 1 root root 182643 Apr 1 13:37 t5.txt
-rw-r--r-- 1 root root 182643 Apr 1 13:37 t6.txt
-rw-r--r-- 1 root root 182643 Apr 1 13:37 t7.txt
-rw-r--r-- 1 root root 182643 Apr 1 13:38 t8.txt
-rw-r--r-- 1 root root 182643 Apr 1 13:38 t9.txt
[root@vm1 ~]#
[root@vm1 ~]# ls -lh
total 1.6M
-rw-r--r-- 1 root root 179K Apr 1 13:36 t1.txt
-rw-r--r-- 1 root root 179K Apr 1 13:37 t2.txt
-rw-r--r-- 1 root root 179K Apr 1 13:37 t3.txt
-rw-r--r-- 1 root root 179K Apr 1 13:37 t4.txt
-rw-r--r-- 1 root root 179K Apr 1 13:37 t5.txt
-rw-r--r-- 1 root root 179K Apr 1 13:37 t6.txt
-rw-r--r-- 1 root root 179K Apr 1 13:37 t7.txt
-rw-r--r-- 1 root root 179K Apr 1 13:38 t8.txt
-rw-r--r-- 1 root root 179K Apr 1 13:38 t9.txt
[root@vm1 ~]#
[root@vm1 ~]# ls -lht
total 1.6M
-rw-r--r-- 1 root root 179K Apr 1 13:38 t9.txt
-rw-r--r-- 1 root root 179K Apr 1 13:38 t8.txt
-rw-r--r-- 1 root root 179K Apr 1 13:37 t7.txt
-rw-r--r-- 1 root root 179K Apr 1 13:37 t6.txt
-rw-r--r-- 1 root root 179K Apr 1 13:37 t5.txt
-rw-r--r-- 1 root root 179K Apr 1 13:37 t4.txt
-rw-r--r-- 1 root root 179K Apr 1 13:37 t3.txt
-rw-r--r-- 1 root root 179K Apr 1 13:37 t2.txt
-rw-r--r-- 1 root root 179K Apr 1 13:36 t1.txt
[root@vm1 ~]#
[root@vm1 ~]#
ls -lht --time-style=long-iso
# ls -lht可以查看文件大小以M来显示
# --time-style=long-iso 显示年月日时分
ls -l --time-style=full-iso #显示精确到毫秒
ls -l --time-style=iso ls -l --time-style=locale #显示月日时分
ls -l --time-style '+%Y/%m/%d %H:%M:%S' #自定义显示方式
参考
https://www.cnblogs.com/sxdcgaq8080/p/10102053.html
https://www.cnblogs.com/iyoume2008/p/6105590.html