Skip to content

Instantly share code, notes, and snippets.

@Ttech
Last active December 17, 2015 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ttech/5625307 to your computer and use it in GitHub Desktop.
Save Ttech/5625307 to your computer and use it in GitHub Desktop.
raw_interfaces=$(ifconfig |
perl -ane '
END{print "\042", join("\042 \042", @a), "\042\n"}
$a[$c++] = $1 if /^(\w+)/;
')
interfaces=($raw_interfaces)
for interface in "${interfaces[@]}"
do
address=$(ifconfig `echo $interface | sed "s/\"//g"` | grep inet)
if [ $? -eq 0 ]; then
echo "Interface $interface"
echo $address
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment