Skip to content

Instantly share code, notes, and snippets.

@hackerb9
Created March 8, 2018 03:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hackerb9/d666f5668e87a6f3dce0afb8df09aa2a to your computer and use it in GitHub Desktop.
Save hackerb9/d666f5668e87a6f3dce0afb8df09aa2a to your computer and use it in GitHub Desktop.
#!/bin/bash
# Watch files in the current working directory (or given argument)
# display how much a file has grown in the last second (or so)
# B9 2018
if [ -d "$1" ]; then
cd "$1"
shift
fi
orig=$(stat --format=$'%n\t%s' *)
old="$orig"
while sleep 1; do
new=$(stat --format=$'%n\t%s' *)
join <(echo "$old") <(echo "$new") |
awk -v tick="'" \
'$2 != $3 { printf ("%" tick "*d %s\n", 20, $3-$2, $1) }'
old="$new"
echo
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment