ネットワーク上のホストリストを作成する
#!/bin/sh #hostlist.sh broadcast='192.168.1.255' ping -c 1 -b $broadcast &> /dev/null sleep 1 IFS_BAK=$IFS IFS=" " for line in `ping -c 1 -b $broadcast 2> /dev/null`; do ip=`expr "$line" : '.*from \(.*\):'` time=`expr "$line" : '.*time\(.*ms\)'` if [ -n "$ip" ]; then echo "$ip(time=$time)" fi done IFS=$IFS_BAK