更新時間: 2013-12-11
介紹
du 是用來查看整棵目錄樹內檔案大小的指令來
du 的應用
tree /root/test/
/root/test/ ├── a │ └── cur │ └── 1.txt ├── b │ └── cur │ └── 2.txt ├── c │ └── cur │ └── 3.txt ├── d │ └── cur │ └── 4.txt └── files.txt
#當前目錄大小:
du -sh
40K .
# -x, --one-file-system
du -xh | sort -n
4.0K ./a/cur 8.0K ./a 4.0K ./b/cur 8.0K ./b 4.0K ./d/cur 8.0K ./d 4.0K ./c/cur 8.0K ./c 40K .
# follow link also
-L, --dereference # 會 count symbolic links 目標的的大小
# Unit
-b, --bytes
# -l, --count-links, count sizes many times if hard linked
ls -l
total 2097152 -rw-r--r-- 2 root root 1073741824 Feb 18 23:31 test1.bin -rw-r--r-- 2 root root 1073741824 Feb 18 23:31 test2.bin
du -h
1.0G .
# 純計隱藏檔案
du -sh \.* --exclude='..'