scripts/shell/ipa.sh
2024-03-20 11:28:46 -05:00

9 lines
193 B
Bash
Executable file

#!/usr/bin/env bash
#
# SPDX-License-Identifier: MIT
[ -n "$1" ] || exit 1
IP=$(ip -4 -o addr show dev "$1" primary 2>/dev/null)
IP=${IP%%/*}
IP=${IP##* }
[ -n "$IP" ] && echo "$IP" || exit 1