#!/bin/bash if [ "$1" == "" ] then echo "You forgot an IP address!" echo "Syntax: ./ipsweep.sh 192.168" else for ip3 in `seq 1 254` do for ip4 in `seq 1 254` do ping -c 1 $1.$ip3.$ip4 | grep "64 bytes" | cut -d " " -f 4 | tr -d ":" & done if [ `expr $ip3 % 3` == 0 ] then wait echo "wait all processes done,`expr $ip3 - 2 `,`expr $ip3 - 1 `,$ip3 subnet done!" fi done fi
前面参考
https://blog.csdn.net/weixin_43623271/article/details/122113368
解释多出来的部分
expr $ip3 % 3
== 0 ]