Last active
January 23, 2016 02:01
-
-
Save darkphase/67d7ec22d47dbebd329e to your computer and use it in GitHub Desktop.
This file contains 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 | |
red="\033[31m" | |
green="\033[32m" | |
blue="\033[34m" | |
yellow="\033[33m" | |
reset="\033[0m" | |
echo -e $green"Detected Interfaces"$reset | |
echo "" | |
# cmd="cat ifconfig.out" | |
cmd="ifconfig" | |
echo ee | awk ' | |
BEGIN { RS = "" ; FS = "\n" } | |
{ | |
while ( "'"$cmd"'" | getline ){ | |
# print $0 | |
if ( $1 !~ /LOOPBACK/ ){ | |
split($1,arr," ") | |
print "'"$blue"'"arr[1]"'"$reset"'" | |
for(i = 1; i <= NF; i++) { | |
split($i,arr," ") | |
switch ( arr[1] ) { | |
case "inet": | |
print "'"$red"'" "IPV4:" "'"$reset"'" "\n IP: " "'"$yellow"'" arr[2] "'"$reset"'" "\n NM: "arr[4]"\n BC: "arr[6] | |
break | |
case "inet6": | |
print "'"$red"'" "IPV6:" "'"$reset"'" "\n IP: "arr[2]"\n PL: "arr[4] | |
break | |
case "ether": | |
print "'"$red"'" "MAC: " "'"$reset"'" arr[2] | |
break | |
default: | |
} | |
} | |
print "" | |
} | |
} | |
}' |
Author
darkphase
commented
Jan 22, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment