Skip to content

Instantly share code, notes, and snippets.

@joar
Last active May 17, 2017 08:28
Show Gist options
  • Save joar/8ca1ec0824b245e5554353914467e087 to your computer and use it in GitHub Desktop.
Save joar/8ca1ec0824b245e5554353914467e087 to your computer and use it in GitHub Desktop.
Diff continuously over du output
#/bin/bash
#
# Usage: du-diff.sh DU_ARGS
PREVIOUS=$(mktemp -t du-diff.prev.XXXXX.txt)
CURRENT=$(mktemp -t du-diff.curr.XXXXX.txt)
echo prev: $PREVIOUS current: $CURRENT > /dev/stderr
INTERVAL=${DU_DIFF_INTERVAL:-1}
while true; do
du $@ > $CURRENT
tput home
tput clear
if test -n "$(cat $PREVIOUS)"; then
diff $PREVIOUS $CURRENT
else
cat $CURRENT
fi
cat $CURRENT > $PREVIOUS
sleep $INTERVAL
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment