Last active
March 5, 2019 08:52
-
-
Save hoangdh/f3130550ead2267bba7c0ee439414280 to your computer and use it in GitHub Desktop.
Get interface's name with IP Address.
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
#!/bin/bash | |
# ifs=`ifconfig -a | grep "flags=" | cut -d":" -f1 | sort -u` | |
for x in `ifconfig -a | grep "flags=" | cut -d":" -f1 | sort -u` # $ifs | |
do | |
IP=`ip -f inet -o addr show $x | cut -d\ -f 7 | cut -d/ -f 1` | |
if [ -z "$IP" ] | |
then | |
echo "${x}: Not connected." | |
else | |
echo "${x}: $IP" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Xoá IP trên Interface: ip addr flush dev XXX