From 5f9c6448a0038a519f4e8bc33b70a593dc8a36b8 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Tue, 15 Oct 2024 12:46:02 +0200 Subject: [PATCH] etc/profile.d/sys.sh --- etc/profile.d/sys.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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() { -- 2.47.3