DEV Community

Cover image for A tool for showing disk usage. (Linux, macOS and Windows)
chenquan
chenquan

Posted on • Updated on

A tool for showing disk usage. (Linux, macOS and Windows)

Use the go to develop a tool to display the current disk usage.
https://github.com/chenquan/diskusage
If you like or are using this project to learn or start your solution, please give it a star⭐. Thanks!

Image description

❗installation

go install github.com/chenquan/diskusage@latest
Enter fullscreen mode Exit fullscreen mode

👏how to use

$ 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")
Enter fullscreen mode Exit fullscreen mode

👀example

  1. Only files named Doc or docx are counted: diskusage -t doc,docx or diskusage -f ".+\.(doc|docx)$"
  2. The maximum display unit is GM: diskusage -u G
  3. Supports color output to pipeline: diskusage -c always | less -R or diskusage -c always | more

Top comments (5)

Collapse
 
raguay profile image
Richard Guay

That’s a nice one too. Just installed it using Homebrew. Thanks.

Collapse
 
raguay profile image
Richard Guay

I like the output of this program. Thanks.

Collapse
 
chenquan profile image
chenquan • Edited

Yes, It's also an interesting project. Thx 😄
If you like or are using this project to learn or start your solution, please give it a star⭐. Thanks!

Collapse
 
fjones profile image
FJones

What's the advantage over using du?

Collapse
 
chenquan profile image
chenquan • Edited

More intuitively display the size of files and directories under the current directory, the list of subdirectories (tree) included, and the actual space occupied and the percentage of the actual space. If you like or are using this project to learn or start your solution, please give it a star⭐. Thanks!