From a6993fc98fa86a5e4b27194ed151bf6dda8ed6b4 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sat, 2 Jan 2021 12:02:04 +0100 Subject: xml: local-ip completion helper should output address only once and sorted When using VRFs a system can have the same IP address multiple times assigned to different VRFs. When listing all the available IP addresses on the system it makes no sense to list this address multiple times. --- src/completion/list_local_ips.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/completion') diff --git a/src/completion/list_local_ips.sh b/src/completion/list_local_ips.sh index a506ce16e..32df8a8b1 100755 --- a/src/completion/list_local_ips.sh +++ b/src/completion/list_local_ips.sh @@ -14,11 +14,11 @@ while [[ "$#" -gt 0 ]]; do done if [ $ipv4 -eq 1 ] && [ $ipv6 -eq 1 ]; then - ip a | grep inet | awk '{print $2}' | sed -e /^fe80::/d | awk -F/ '{print $1}' + ip a | grep inet | awk '{print $2}' | sed -e /^fe80::/d | awk -F/ '{print $1}' | sort -u elif [ $ipv4 -eq 1 ] ; then - ip a | grep 'inet ' | awk '{print $2}' | awk -F/ '{print $1}' + ip a | grep 'inet ' | awk '{print $2}' | awk -F/ '{print $1}' | sort -u elif [ $ipv6 -eq 1 ] ; then - ip a | grep 'inet6 ' | awk '{print $2}' | sed -e /^fe80::/d | awk -F/ '{print $1}' + ip a | grep 'inet6 ' | awk '{print $2}' | sed -e /^fe80::/d | awk -F/ '{print $1}' | sort -u else echo "Usage:" echo "-4|--ipv4 list only IPv4 addresses" -- cgit v1.2.3