- 论坛徽章:
- 0
|
5可用积分
PING 192.168.4.1 (192.168.4.1) 56(84) bytes of data.
64 bytes from 192.168.4.1: icmp_seq=1 ttl=128 time=0.284 ms
--- 192.168.4.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.284/0.284/0.284/0.000 ms
PING 192.168.5.1 (192.168.5.1) 56(84) bytes of data.
From 192.168.4.202 icmp_seq=1 Destination Host Unreachable
--- 192.168.5.1 ping statistics ---
1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms
PING 192.168.4.2 (192.168.4.2) 56(84) bytes of data.
64 bytes from 192.168.4.2: icmp_seq=1 ttl=255 time=0.980 ms
--- 192.168.4.2 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.980/0.980/0.980/0.000 ms
PING 192.168.5.2 (192.168.5.2) 56(84) bytes of data.
From 192.168.4.202 icmp_seq=1 Destination Host Unreachable
--- 192.168.5.2 ping statistics ---
1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms
PING 192.168.4.3 (192.168.4.3) 56(84) bytes of data.
64 bytes from 192.168.4.3: icmp_seq=1 ttl=64 time=1.27 ms
怎么把上面的数据ping通的ip地址给挑选出来?
或者有什么更好的方法把一个网段能ping通的主机给挑选出来? |
最佳答案
查看完整内容
[root@Mylinux tmp]# awk '/PING/{ip=$2}/time=/{print ip}' file192.168.4.1192.168.4.2192.168.4.3[root@Mylinux tmp]# awk '/time=/{sub(//,"",$4);print $4}' file 192.168.4.1192.168.4.2192.168.4.3[ 本帖最后由 ywlscpl 于 2010-1-3 14:49 编辑 ]
|