版权声明:此文乃鄙人辛辛耕耘制作,饮其流者怀其源,请标明出处,跪谢!!! https://blog.csdn.net/CSDN_LJie/article/details/81504499
#!/bin/bash
function whether_changed(){
file_path=$1
file_old_stat="`stat ${file_path}|grep Modify`"
while [[ true ]]; do
sleep 2s
if [ -f "$file_path" ]; then
file_new_stat="`stat ${file_path}|grep Modify`"
if [[ `echo ${file_old_stat}` == `echo ${file_new_stat}` ]]; then
echo "### In ${check_time}s ,${file_path} does not change ###"
else
echo ${file_new_stat}
echo ${file_old_stat}
file_old_stat=${file_new_stat}
echo "file change"
# $2 2>&1 >/dev/null &
fi
else
echo "file no exit "
fi
done
}
whether_changed $1 $2