#!/bin/bash function doPing () { # $1 = target # $2 = letter ping -c1 -W1 "$1" | \ (grep "bytes from" || echo "$2:Down") | \ sed 's/.*time=\([0-9\.]*\).*/'"$2"':\1ms/' } function get_ip_addresses() { ip -4 -json address | jq -r --arg ifregex "${1:-lo}" ' map(select(.ifname | test($ifregex) | not) | .ifname + ":" + (.addr_info | map(.local) | join(","))) | join(" ") ' } echo -n "$(get_ip_addresses "$1") $(doPing 8.8.8.8 G)"