将巡检的设备状态信息文件 放到和shell脚本一个目录下,执行bash 脚本名称
for filename in $(ls | grep SD1);do
device_model=$(cat $filename | grep "'s Device status" | cut -d"'" -f 1)
if [[ $device_model = "NE40E-X8" ]];then
sysname=$(cat $filename | grep ^sysname | cut -d" " -f 2)
display_device=$(grep -E "^[0-9]{1,2} {7,9}" $filename | awk '{print $5}'| uniq)
if [[ $display_device = "Normal" ]];then
echo "ok $sysname"
else echo "error $sysname"
fi
else
sysname=$(cat $filename | grep ^sysname | cut -d" " -f 2)
display_device=$(grep -E "^([0-9]{1,2} |FAN|PWR|CMU|SFU).{1,4}-.{1,6}([A-Z]|-)" $filename | awk '{print $7}'| uniq)
if [[ $display_device = "Normal" ]];then
echo "ok $sysname"
else echo "error $sysname"
fi
fi
done
标签:sysname,shell,grep,filename,device,echo,display,板卡,路由器
From: https://www.cnblogs.com/wefjack/p/17274225.html