Skip to content

Latest commit

 

History

History
17 lines (15 loc) · 301 Bytes

38.md

File metadata and controls

17 lines (15 loc) · 301 Bytes

题目要求

写一个shell脚本,把192.168.0.0/24网段在线的ip列出来。

参考答案

#!/bin/bash
for i in `seq 1 254`
do 
    if ping -c 2 -W 2 192.168.0.$i >/dev/null 2>/dev/null
    then
	echo "192.168.0.$i 是通的."
    else
	echo "192.168.0.$i 不通."
    fi
done