#!/bin/bash
set -euo pipefail

# ----------------------------------------------------------------------------
# Example output from ifconfig:
#-----------------------------------------------------------------------------
# $ ifconfig eth2
# eth2      Link encap:Ethernet  HWaddr 3c:fd:fe:71:ff:4a
#           inet addr:10.66.12.147  Bcast:10.66.12.255  Mask:255.255.255.0
#           inet6 addr: fe80::3efd:feff:fe71:ff4a/64 Scope:Link
#           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
#           RX packets:685416 errors:0 dropped:0 overruns:0 frame:0
#           TX packets:174847 errors:0 dropped:0 overruns:0 carrier:0
#           collisions:0 txqueuelen:1000
#           RX bytes:936125642 (936.1 MB)  TX bytes:28005597 (28.0 MB)
# ----------------------------------------------------------------------------
# This will return 10.66.12.147
function filter_address() {
    awk '/inet addr/ {print $2}' |  sed "s/addr://"
}

remote_command ifconfig wall | filter_address
