Created
December 6, 2016 11:15
-
-
Save janbuecker/d2a4ef5519ea9778637dece6bed4f54b to your computer and use it in GitHub Desktop.
compare_folders.sh
This file contains 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
// Usage: compare_folder <dir1> <dir2> | |
// | |
// Output: | |
// | |
// $ compare_folder dir1 dir2 | |
// | |
// Changes in permissions | |
// drwxr-xr-x/update | drwxr-xr-x/update_original | |
// -rwxrwxr-x/console | -rw-r--r--/console | |
// -rwxrwxr-x/clear_cache.sh | -rw-r--r--/clear_cache.sh | |
// | |
// Changes in contents | |
// Files update/engine/Shopware/Application.php and update_original/engine/Shopware/Application.php differ | |
// Files update/engine/Shopware/Components/Check/Data/Files.md5sums and //update_original/engine/Shopware/Components/Check/Data/Files.md5sums differ | |
// Files update/update-assets/snippets.sql and update_original/update-assets/snippets.sql differ | |
#!/bin/bash | |
function removeTemporaryFiles() { | |
rm a.diff b.diff | |
} | |
function printUsage() { | |
echo "Usage: $(basename $0) <dir1> <dir2>" | |
} | |
if [[ $1 == "" ]] || [[ $2 == "" ]]; then | |
printUsage; | |
exit 1; | |
fi | |
find $1 -ls -type f | awk '{ gsub("^.*/","",$11); printf "%s/%s\n", $3, $11; }' > a.diff | |
find $2 -ls -type f | awk '{ gsub("^.*/","",$11); printf "%s/%s\n", $3, $11; }' > b.diff | |
echo "Changes in permissions" | |
diff -y --suppress-common-lines a.diff b.diff | |
echo | |
echo "Changes in contents" | |
diff -rq $1 $2 | |
removeTemporaryFiles; | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No need for temporary files: