Think before you speak, read before you think.

du命令使用的例子

du–用来计算文件占用空间的命令

例1:显示当前目录下的各文件夹大小(并不显示单个文件的大小),最后一行显示的是当前目录的总大小

du -h --max-depth=1
4.0K ./hob
232M ./chan
4.0K ./1d4
291M ./ngjewel
4.0K ./gzjul
4.0K ./lifi
728M .

例2:显示 work/testing下的目录大小

# du -h --max-depth=1 work/testing
27M work/testing/logs
35M work/testing

显示 work/testing/下面所有文件和目录大小

du -h --max-depth=1 work/testing/*
8.0K work/testing/func.php
27M work/testing/logs
8.1M work/testing/nohup.out

例3:遍历显示子目录及子文件的大小

du -ha

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *