「自身のIPアドレス」は一つとは限りませんので、loopback と IPv6 link-local を除く全てのアドレスをチェックしています。
bash
1#!/bin/bash
2
3declare -a ip_addrs=$(hostname -I)
4for addr in ${ip_addrs[@]}
5do
6 if ping -q -c 10 -i 2 $addr | grep -qE ', 0% packet loss';then
7 echo "($addr)さんは正常に動作されています。"
8 fi
9done
hostname(1)
-I, --all-ip-addresses
Display all network addresses of the host. This option enumerates all configured addresses on all network interfaces. The loopback interface and IPv6 link-local addresses are omitted. Contrary to option -i, this option does not depend on name resolution. Do not make any assumptions about the order of the output.