創作背景:
在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