check_ok() { if [ $? -eq 0 ];then echo "$ip UP" else echo "$ip DOWN" fi } for i in `seq 1 255` do ip=`ifconfig|awk -F [:a-Z" "]+ 'NR==2 {print $2}'|cut -d. -f1,2,3`.$i ping -c1 -w1 $ip &>/dev/null check_ok done