Last active
January 4, 2016 07:18
-
-
Save patrickkettner/8587290 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# "diff" two different directories, outputting the filesize difference between them. | |
# | |
# $ diffdir foo bar | |
# baz.js: 52b 56p - -4b | |
# 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" | |
file1size=$(du -k "$file1" | cut -f1) | |
file2size=$(du -k "$file2" | cut -f1) | |
echo $filename $file1size $file2size - $(expr $file1size - $file2size) | |
done; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
du
outputs in blocks, butstat -f "%z"
does the trick (outputs in bytes)