Skip to content

Instantly share code, notes, and snippets.

@stanwu
Created July 25, 2012 03:22
Show Gist options
  • Save stanwu/3174176 to your computer and use it in GitHub Desktop.
Save stanwu/3174176 to your computer and use it in GitHub Desktop.
batch make md5 check sum for files (find -exec)
#!/bin/bash
b=`basename "$1"`
d=`pwd`
echo "[RUN] Check [$b] $d/$1"
if [ -f "$1" ]; then
if [ -s "$1.md5" ]; then
s=`cat "$1.md5" | awk '{print $1}'`
else
echo "[RUN] Rebuilt $1 md5sum"
s=`md5sum "$1" | awk '{print $1}'`
echo "$s $b" > "$1.md5"
fi
echo "[MD5] $s"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment