#! /usr/bin/env bash
#
# Returns a list of the IP addresses associated with local interfaces.
# For IPv6 addresses, zone_id and prefix length are removed if present.

# On Linux, ifconfig is often not in the user's standard PATH.
export PATH=$PATH:/sbin:/usr/sbin

# Tested the pattern with Linux, FreeBSD and MacOS.
ifconfig -a | sed -n 's/.*inet6\{0,1\} \(addr: *\)\{0,1\}\([^ ]*\).*/\2/gp' | sed 's/%.*$//g' | sed 's/\/.*$//g'
