Skip to content

Instantly share code, notes, and snippets.

@AaronHarris
Created March 21, 2014 00:58
Show Gist options
  • Save AaronHarris/9677388 to your computer and use it in GitHub Desktop.
Save AaronHarris/9677388 to your computer and use it in GitHub Desktop.
Compare two directories
#!/bin/bash
shopt -s dotglob
for file in "$1"/*; do [[ -f "$file" ]] && d1+=( "$(md5sum < "$file")" ); done
for file in "$1"/*; do [[ -f "$file" ]] && d1+=( "$(md5sum < "$file")" ); done
[[ "$(sort <<< "${d1[*]}")" == "$(sort <<< "${d2[*]}")" ]] && echo "Same" || echo "Different"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment