判断目录下文件修改

#!/bin/bash

#需要判断的目录
PWD=/mnt/sda1/upper/www/blog/content/posts/

MD5NEW() {
find $PWD -type f|cut -d' ' -f1|xargs md5sum > /tmp/md5new
}

MD5OLD() {
mv /tmp/md5new /tmp/md5old
}

if [ ! -f /tmp/md5old ];then
    MD5NEW && MD5OLD
    echo 更新1
elif [ $(MD5NEW && md5sum /tmp/md5new|awk '{print $1}') != $(md5sum /tmp/md5old|awk '{print $1}') ];then
    MD5OLD
    echo 更新2
fi