tail -F /var/log/message | while read line; do if [ "$line" = *"关键字"* ]; then echo "找到了关键字" fi done
@freeor,↑
@freeor,使用单步调试器,比如bashdb
@freeor,↑
# 检查ptp状态(Master 是ptp状态如果ptp正常显示update,如果不正常显示Master
log=`cat /var/log/messages |grep "ptp4l"|tail -n 1|awk -F' ' '{printf$10}'`
echo $log
netstate=`ifconfig -a|grep "BROADCAST"|awk -F' ' '{printf$3}'`
echo $netstate
if [ "${log}" = "Master"]; then
#if not exit start reboot
# reboot
if [ "${netstate}" = "RUNNING" ]; then
echo "hello world"
sleep 5
fi
sleep 5
fi
sleep 10
done
我这样写的 master和runner可以打印出来,Hello world打印不出来
@老虎会游泳
@freeor,使用单步调试器,比如bashdb