AGa*_*yer 35 ls shell bash directory disk-usage
我知道我可以使用 du -h 输出目录的总大小。但是当它包含其他子目录时,输出将类似于:
du -h /root/test
.
.
.
.
24K /root/test/1
64K /root/test/2
876K /root/test/3
1.1M /root/test/4
15M /root/test/5
17M /root/test
Run Code Online (Sandbox Code Playgroud)
我只想要最后一行,因为目录中的小目录太多/root/test。我能做什么?
Joh*_*ohn 57
添加--max-depth值为 0的参数:
du -h --max-depth=0 /root/test
Run Code Online (Sandbox Code Playgroud)
或者,使用-s(摘要)选项:
du -sh /root/test
Run Code Online (Sandbox Code Playgroud)
其中任何一个都应该给你你想要的。供以后参考,man du很有帮助。