【shell学习】扫描局域网IP的方法
[font=punctuation, 微软雅黑, Tohoma]#!/bin/bash
[font=punctuation, 微软雅黑, Tohoma]mynet="192.168.2"
[font=punctuation, 微软雅黑, Tohoma]num=1
[font=punctuation, 微软雅黑, Tohoma]for num in {1..254}
[font=punctuation, 微软雅黑, Tohoma]do
[font=punctuation, 微软雅黑, Tohoma] if ping $mynet.$num -c 1 &> /dev/null
[font=punctuation, 微软雅黑, Tohoma] then
[font=punctuation, 微软雅黑, Tohoma] echo "$mynet.$num is alived"
[font=punctuation, 微软雅黑, Tohoma] else
[font=punctuation, 微软雅黑, Tohoma] echo "$mynet.$num not is alived"
[font=punctuation, 微软雅黑, Tohoma] fi
[font=punctuation, 微软雅黑, Tohoma] num+=1
[font=punctuation, 微软雅黑, Tohoma]done