#!/bin/bash # Author: 电脑程序爱好者 # Date & Time: 2021-04-26 10:03:59 # Description: trap break INT # ctrl+c ,break loop for i in 192.168.1.{1..10}; do echo "begin to test $i" # ping 的参数 -c 3 意思是测试3次, if ! ping -c 3 $i &>/dev/null; then echo "$i" is off line. fi done