#!/bin/bash #test alive ip a=1 while : do a=$(($a+1)) if test $a -gt 255 then break else ip_addr=$(ifconfig | grep inet | head -n 1 | awk ‘{print $2}‘ | awk -F : ‘{print $2}‘| awk -F . ‘{print $1"."$2"."$3}‘) ip=$ip_addr.$a result=$(ping -c 1 $ip) if [[ $? == 0 ]] then echo $ip:ok >> ip.txt else echo $ip:no >>ip.txt fi fi done
时间: 2024-11-02 09:47:49