我的剧本:
date
echo -e "${YELLOW}Network check${NC}\n\n"
while read hostname
do
ping -c 1 "$hostname" > /dev/null 2>&1 &&
echo -e "Network $hostname : ${GREEN}Online${NC}" ||
echo -e "${GRAY}Network $hostname${NC} : ${RED}Offline${NC}"
done < list.txt
sleep 30
clear
done
正在输出这样的信息:
Network 10.x.xx.xxx : Online
Network 10.x.xx.xxx : Offline
Network 10.x.xx.xxx : Offline
Network 10.x.xx.xxx : Offline
Network 10.x.xx.x : Online
Network 139.xxx.x.x : Online
Network 208.xx.xxx.xxx : Online
Network 193.xxx.xxx.x : Online
我想清理得到这样的东西:
Network 10.x.xx.xxx : Online
Network 10.x.xx.xxx : Offline
Network 10.x.xx.xxx : Offline
Network 10.x.xx.x : Online
Network 139.xxx.x.x : Online
Network 208.xx.xxx.xxx : Online
Network 193.xxx.xxx.x : Online
Network 193.xxx.xxx.xxx : Offline