9 lines
193 B
Bash
Executable file
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
|