比du更好用的磁盘空间统计工具-diskusage

1. 介绍

官网地址:https://github.com/chenquan/diskusage/blob/master/README-CN.md

diskusage:一个显示磁盘使用情况的工具。(Linux、MacOS 和 Windows)

2. 安装

[root@k8s-node01 ~]# wget https://github.com/chenquan/diskusage/releases/download/v1.1.4/diskusage-v1.1.4-linux-amd64.tar.gz
[root@k8s-node01 ~]# ll
-rw-------  1 root root  2749766 510 13:42 diskusage-v1.1.4-linux-amd64.tar.gz
[root@k8s-node01 ~]# tar xf diskusage-v1.1.4-linux-amd64.tar.gz -C /usr/locl/bin

3. 使用

3.1 参数

[root@k8s-node01 ~]# diskusage -h
A tool for showing disk usage.

GitHub: https://github.com/chenquan/diskusage
Issues: https://github.com/chenquan/diskusage/issues

Usage:
  diskusage [flags]

Examples:
1.The maximum display unit is GB: diskusage -u G 
2.Only files named doc or docx are counted:
  a.diskusage -t doc,docx 
  b.diskusage -f ".+\.(doc|docx)$"
3.Supports color output to pipeline: 
  a.diskusage -c always | less -R
  b.diskusage -c always | more
4.Displays a 2-level tree structure: diskusage -d 2
5.Specify the directory /usr: diskusage --dir /usr
6.Export disk usage to file: diskusage > diskusage.txt

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      directory path (default "./")
  -D, --directory       only display directory
  -f, --filter string   regular expressions are used to filter files
  -h, --help            help for diskusage
  -l, --limit int       limit the number of files and directories displayed (default 9223372036854775807)
  -r, --recursion       automatically calculate directory depth, for recursively traversing all sub directories
  -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")
  -v, --version         version for diskusage
  -w, --worker int      number of workers searching the directory (default 32)

在这里插入图片描述

3.2 使用演示

3.2.1 统计指定目录下的所有文件

# 两种方式
## 方式1:指定目录
[root@k8s-node01 ~]# diskusage --dir / 
Total: 5910.655M        /
-----------------------------
 2506.2M  42.4% ┌─ usr
 1361.6M  23.0% ├─ data
  876.6M  14.8% ├─ var
  554.9M   9.4% ├─ run
  352.4M   6.0% ├─ sys
  162.6M   2.8% ├─ boot
   68.3M   1.2% ├─ root
   28.1M   0.5% ├─ etc
    1.4K   0.0% ├─ dev
   37.0B   0.0% ├─ tmp
    9.0B   0.0% ├─ lib64
    8.0B   0.0% ├─ sbin
    7.0B   0.0% ├─ lib
    7.0B   0.0% ├─ bin
    0.0B   0.0% └─ .autorelabel

## 方式2:cd到指定目录
[root@k8s-node01 ~]# cd /
[root@k8s-node01 /]# diskusage 
Total: 5910.658M        /
-----------------------------
 2506.2M  42.4% ┌─ usr
 1361.6M  23.0% ├─ data
  876.6M  14.8% ├─ var
  554.9M   9.4% ├─ run
  352.4M   6.0% ├─ sys
  162.6M   2.8% ├─ boot
   68.3M   1.2% ├─ root
   28.1M   0.5% ├─ etc
    1.4K   0.0% ├─ dev
   37.0B   0.0% ├─ tmp
    9.0B   0.0% ├─ lib64
    8.0B   0.0% ├─ sbin
    7.0B   0.0% ├─ lib
    7.0B   0.0% ├─ bin
    0.0B   0.0% └─ .autorelabel

3.2.2 GB级别显示

[root@k8s-node01 ~]# diskusage --dir / -u G
Total: 5.772G   /
--------------------------
  2.4G  42.4% ┌─ usr
  1.3G  23.0% ├─ data
  0.9G  14.8% ├─ var
  0.5G   9.4% ├─ run
  0.3G   6.0% ├─ sys
  0.2G   2.8% ├─ boot
 68.3M   1.2% ├─ root
 28.1M   0.5% ├─ etc
  1.4K   0.0% ├─ dev
 37.0B   0.0% ├─ tmp
  9.0B   0.0% ├─ lib64
  8.0B   0.0% ├─ sbin
  7.0B   0.0% ├─ lib
  7.0B   0.0% ├─ bin
  0.0B   0.0% └─ .autorelabel
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值