Skip to content

Instantly share code, notes, and snippets.

@mca-gif
Created March 12, 2015 23:22
Show Gist options
  • Save mca-gif/10c55eab8a9a15217c9f to your computer and use it in GitHub Desktop.
Save mca-gif/10c55eab8a9a15217c9f to your computer and use it in GitHub Desktop.
Run diff on set of files which possibly changed over time
#!/bin/bash
if [[ $# -lt 2 ]]; then
echo "$0 <file1> <file2> <file3> [file4]"
echo "This script is meant to run on 3 or more files, to see the changes over time."
exit 1
fi
while [[ $# -ge 2 ]]; do
TEST=$(diff -q $1 $2)
if [ -n "$TEST" ]; then
echo ""
echo "$2"
diff $1 $2
fi
shift
done
@mca-gif
Copy link
Author

mca-gif commented Mar 12, 2015

My use case was a set of XML files which were uploaded by a 3rd party service multiple times a day, regardless of whether the data changed. Using this, I was able to figure out which files had changes, and what those specific changes were.

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