Skip to content

Instantly share code, notes, and snippets.

@arthuralvim
Forked from deltheil/md5deep.sh
Created October 22, 2016 21:28
Show Gist options
  • Save arthuralvim/9033ab1f8a89ad69dd51e94453570206 to your computer and use it in GitHub Desktop.
Save arthuralvim/9033ab1f8a89ad69dd51e94453570206 to your computer and use it in GitHub Desktop.
Files and directory comparison with md5deep matching mode (see http://md5deep.sourceforge.net/start-md5deep.html#match).
# Create a reference folder with some data
mkdir foo
echo "hey" > foo/A.txt
echo "scm" > foo/B.txt
echo "git" > foo/C.txt
# Generate the list of hashes for each file
# -b = bare mode (strips any leading directory
# information from displayed filenames)
md5deep -b foo/* > hashes.txt
# Create a modified folder with some changes
# A.txt: modified
# C.txt: deleted
# D.txt: added
mkdir bar
echo "HEY" > bar/A.txt
echo "scm" > bar/B.txt
echo "svn" > bar/D.txt
# Find the positive matches with the -m option
# ~ find all unmodified files
md5deep -bm hashes.txt bar/*
# => B.txt
# Find the negative matches with the -x option
# ~ find all added or modified files
md5deep -bx hashes.txt bar/*
# => A.txt
# => D.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment