Skip to content

Instantly share code, notes, and snippets.

@ongardie
Created May 29, 2015 19:31
Show Gist options
  • Save ongardie/85c863bb52106cb8017e to your computer and use it in GitHub Desktop.
Save ongardie/85c863bb52106cb8017e to your computer and use it in GitHub Desktop.
Print changes over time in program output
#!/bin/bash
out1=$(mktemp)
out2=$(mktemp)
$* > $out1
date -u --rfc-3339=ns
cat $out1
echo
while true; do
sleep ${FREQ:-2}
$* > $out2
if ! diff -q $out1 $out2 > /dev/null; then
date -u --rfc-3339=ns
diff -u $out1 $out2
echo
mv $out2 $out1
fi
done
@ongardie
Copy link
Author

TODO: clean up temp files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment