go工具-显示磁盘使用情况的工具diskusage
使用 go 开发一个工具来显示当前的磁盘使用情况。
官方: https://github.com/chenquan/diskusage
安装:
go install github.com/chenquan/diskusage@latest
[root@dev workspace]# diskusage -h
A tool for showing disk usage.
Usage:
diskusage [flags]
Flags:
-a, --all display all directories, otherwise only display folders whose usage size is not 0
-c, --color string set color output mode. optional: auto, always, ignore (default "auto")
-d, --depth int shows the depth of the tree directory structure (default 1)
--dir string dir path (default "./")
-f, --filter string regular expression filter (default ".+")
-h, --help help for diskusage
-t, --type strings only count certain types of files (default all)
-u, --unit string displayed units. optional: B(Bytes), K(KB), M(MB), G(GB), T(TB) (default "M")
[root@dev workspace]#
-a 显示所有目录,否则仅显示使用大小不是0的文件夹
-c 设置颜色输出模式。可选:自动,始终忽略(默认“自动”)
-d 显示树目录结构的深度(默认1)
-f 正则表达式过滤器(默认".+")
-t 仅计算某些类型的文件(默认所有文件)
-u 显示单位。可选:B(字节),K(KB),M(MB),G(GB),T(TB)(默认为“ M”)
demo命令:
diskusage -a -c always -d 1 -u G
例子
计算名为 coc 或 docx 的文件: diskusage -t doc,docx或diskusage -f ".+\.(doc|docx)$"
最大显示单位为GB:diskusage -u G
支持颜色输出到管道:` diskusage -c always | less -R ``