From: Nicolas Boisselier Date: Tue, 15 Oct 2024 10:46:02 +0000 (+0200) Subject: etc/profile.d/sys.sh X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=5f9c6448a0038a519f4e8bc33b70a593dc8a36b8;p=nb.git etc/profile.d/sys.sh --- diff --git a/etc/profile.d/sys.sh b/etc/profile.d/sys.sh index 2f1fe45a..fecae827 100644 --- a/etc/profile.d/sys.sh +++ b/etc/profile.d/sys.sh @@ -222,7 +222,13 @@ sys_ips() { ips() { shell_help "Usage: $FUNCNAME [INTERFACE]. Print ip adresses." "$@" && return 1 - ( ip addr show || ifconfig ) 2>/dev/null | awk '/^[\t ]*inet /{sub("^[^0-9]*","",$2); sub("/[0-9]+","",$2); if ($2 != "127.0.0.1"){print $2}}' + if which ip 2>/dev/null + then + ip -o addr show | awk -F'[ /]+' '/ inet / && $4 != "127.0.0.1" {print $4}' + else + ifconfig 2>/dev/null | awk '/ inet / && $2 != "127.0.0.1" {print $2}' + fi + # NB 15.10.24 ( ip addr show || ifconfig ) 2>/dev/null | awk '/^[\t ]*inet /{sub("^[^0-9]*","",$2); sub("/[0-9]+","",$2); if ($2 != "127.0.0.1"){print $2}}' } sys_cpu_load() {