Last active
November 16, 2020 21:23
-
-
Save elmundio87/4d560701ab8530ff4e47d591fe47ebea to your computer and use it in GitHub Desktop.
A script to get the primary IP address on linux or mac
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
if [[ "$OSTYPE" == "linux-gnu"* ]]; then | |
ip route get 1 | awk '{print $NF;exit}' | |
elif [[ "$OSTYPE" == "darwin"* ]]; then | |
# Mac OSX | |
ipconfig getifaddr en0 | |
else | |
# Unknown. | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment