Last active
August 29, 2015 14:05
-
-
Save likejazz/c682606a3a98049a7b25 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
PLATFORM=`uname` | |
if [[ "$PLATFORM" == 'Darwin' ]]; then # Mac | |
IP=`/sbin/ifconfig en0 | grep inet | grep -v inet6 | awk '{print $2}'` | |
elif [[ "$PLATFORM" == 'Linux' ]]; then # Linux | |
IP=`/sbin/ifconfig eth0 | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*'` | |
fi | |
print $IP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment