-
-
Save YourFriendCaspian/3c73993bef5975bfe50bc972cf8e4ba0 to your computer and use it in GitHub Desktop.
Get ip addresses for each interface in linux with bash function.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
showips() { | |
NAMES=( $($IFC | grep "lo\|eth\|wlan" -A 1 | awk -F" " '{print $1 }' | grep -v "inet\|-\|UP" | sort -u) ) | |
for i in "${NAMES[@]}" | |
do | |
echo "$i has ip address: `$IFC | grep "$i" -A 1 | grep "addr" | awk -F" " '{print $2}' | awk -F":" '{print $2}'`" | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment