HomeDevCentral

Parse and sum size expressions like 1G or 200M

Description

Parse and sum size expressions like 1G or 200M

Summary:
ZFS commands like zfs list -t snapshot display sizes easy to read
by humans like 0B, 5K, 1G, 200M or 3T.

To answer questions like "What's the total size of all the snapshots
for that dataset?", this means to be able to compute basic additions
using terms with units.

This utility can do this:

zfs list -t snapshot | grep name | awk '{print $2}' | space-sum

Test Plan:

  • cargo build
  • space-sum -h
  • zfs list ... > zfs-sizes.txt ; space-sum zfs-sizes.txt
  • zfs list ... | space-sum

Reviewers: dereckson

Reviewed By: dereckson

Differential Revision: https://devcentral.nasqueron.org/D3254

Details

Provenance
derecksonAuthored on Dec 25 2023, 19:08
derecksonPushed on Dec 25 2023, 20:09
Reviewer
dereckson
Differential Revision
D3254: Parse and sum size expressions like 1G or 200M
Branches
Unknown
Tags
Unknown
References
HEAD -> main