Skip to content

Instantly share code, notes, and snippets.

@icholy
Created September 13, 2013 18:19
Show Gist options
  • Save icholy/6554201 to your computer and use it in GitHub Desktop.
Save icholy/6554201 to your computer and use it in GitHub Desktop.
command output diff
#!/bin/sh
#
# Usage:
#
# ./diff_exec.sh lsof -p <PID>
#
# Every time you hit enter it will run the command
# and display the diff between the current and previous output.
#
prev_output=prev.out
curr_output=curr.out
touch $prev_output $curr_output
while true; do
eval "$@" > $curr_output
diff $prev_output $curr_output | colordiff
cat $curr_output > $prev_output
echo > $curr_output
read
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment