Skip to content

Instantly share code, notes, and snippets.

@patrickkettner
Last active January 4, 2016 07:09
Show Gist options
  • Save patrickkettner/8586233 to your computer and use it in GitHub Desktop.
Save patrickkettner/8586233 to your computer and use it in GitHub Desktop.
#!/bin/bash
# "diff" two different directories, outputting the filesize difference between them.
#
# $ diffdir foo bar
# foo/baz.js: 52b
# bar/baz.js: 50b
# ensure we are only dealing with two directories
if [[ "$#" -ne 2 || !( -d "$1" && -d "$2") ]]; then
echo "need to pass two valid directories";
exit 1
fi
FILES_TO_DIFF=$(/usr/bin/diff -qr "$1" "$2" | awk '{print $2}')
for file in $FILES_TO_DIFF; do
filename=$(basename $file);
file1="$1"/"$filename"
file2="$2"/"$filename"
echo $file1: $(du -k "$file1" | cut -f1)b
echo $file2: $(du -k "$file2" | cut -f1)b
echo ''
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment