[root@rhel77 ~]# cat md5sum.sh
!/bin/bash
FILES="/etc/passwd"
while true
do
echo "The Time is $(date +%F-%T)"
OLD=$(md5sum $FILES | cut -d" " -f 1)
sleep 5
NEW=$(md5sum $FILES | cut -d" " -f 1)
if [ $OLD != $NEW ];then
echo "The $FILES has been modified."
break
else
echo "The $FILES has not been modified."
fi
done
[root@rhel77 ~]#
其中,date参数:
%F:full date; same as %Y-%m-%d
%T:time; same as %H:%M:%S