Forked from kazuhito-m/test_of_ping_ip_range.sh
Last active
December 18, 2022 10:41
-
-
Save kmikage/a39e30e18aa95451d222ec514addd01c to your computer and use it in GitHub Desktop.
同一ネットワーク内で応答のあるIPをシュッと調べる
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
IP_HEAD='192.168.1.' | |
IP_START=1 | |
IP_END=254 | |
function hittest_ip() { | |
i=${1} | |
hittest_ip=${IP_HEAD}${i} | |
ping -c 1 -w 1 ${hittest_ip} > /dev/null | |
if [ ${?} -eq 0 ]; then | |
echo "応答のあったIP:${hittest_ip}" | |
fi | |
} | |
for i in $(seq ${IP_START} ${IP_END}); do | |
hittest_ip ${i} & | |
done | |
wait | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
update
fpingでもいいのかも知れないけど、aptなりyumが使えない環境だと、こっちの方が素直な気がしたので。