summaryrefslogtreecommitdiff
path: root/bin/format-bytes
diff options
context:
space:
mode:
authorSam Nystrom <sam@samnystrom.dev>2026-01-13 18:07:21 -0500
committerSam Nystrom <sam@samnystrom.dev>2026-01-13 18:07:21 -0500
commitf24f6ea00f245e0ba1e593f954267f7eefd59c8a (patch)
tree1ceb6037c1c94d403e2748039f6fe35f561cdbf1 /bin/format-bytes
parentcfa85684d648c8a3b1417ab01cb9acb8dd7f15c6 (diff)
update eww config
Diffstat (limited to 'bin/format-bytes')
-rwxr-xr-xbin/format-bytes11
1 files changed, 11 insertions, 0 deletions
diff --git a/bin/format-bytes b/bin/format-bytes
new file mode 100755
index 0000000..0e2e32d
--- /dev/null
+++ b/bin/format-bytes
@@ -0,0 +1,11 @@
+#!/usr/bin/awk -f
+{
+ if ($1 < 1024) print int($1)" B"
+ else if ($1 < 1024^2) print int($1 / 1024)" KiB"
+ else if ($1 < 1024^3) print int($1 / 1024^2)" KiB"
+ else if ($1 < 1024^4) print int($1 / 1024^3)" MiB"
+ else if ($1 < 1024^5) print int($1 / 1024^4)" GiB"
+ else if ($1 < 1024^6) print int($1 / 1024^4)" TiB"
+ else if ($1 < 1024^7) print int($1 / 1024^4)" PiB"
+ else print int($1 / 1024^7)" EiB"
+}