欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  网络运营

Shell脚本实现检测文件是否被修改过代码分享

程序员文章站 2022-06-20 20:18:25
#!/bin/bash funmd5_1() { find /root/passwd -type f | xargs md5sum > /tmp/funm...
#!/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