Skip to content

Instantly share code, notes, and snippets.

@countingpine
Created January 16, 2021 10:56
Show Gist options
  • Save countingpine/5caa1129562e815ee469d14f64683402 to your computer and use it in GitHub Desktop.
Save countingpine/5caa1129562e815ee469d14f64683402 to your computer and use it in GitHub Desktop.
duwatch.sh
#!/bin/bash
# watch du output every 10s, return size in KB/MB/GB, difference in KB/MB
# (Assumes du output is in KB)
set -u
path="${1:-.}"
while du -s "$path"; do sleep 10; done |
awk '{printf "%dK\t%dM\t%dG\t+%dK\t+%dM\n", $1, $1/1024, $1/1048576, ($1-old), ($1-old)/1024 ; old = $1}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment