怎么用Shell脚本实现检测文件是否被修改过的功能

本篇内容介绍了“怎么用Shell脚本实现检测文件是否被修改过的功能”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

#!/bin/bash
funmd5_1() {
find /root/passwd -type f | xargs md5sum > /tmp/funmd5_1.log
}
funmd5_2() {
find /root/passwd -type f | xargs md5sum > /tmp/funmd5_2.log
}
if [ ! -f /tmp/funmd5_1.log ];then
funmd5_1
fi
funmd5_2
diff /tmp/funmd5_1.log /tmp/funmd5_2.log > /tmp/diff.log
Status=$?
if [ $Status = 0 ];then
exit
else
echo "文件修改过了!"
fi

“怎么用Shell脚本实现检测文件是否被修改过的功能”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注网站,小编将为大家输出更多高质量的实用文章!