Created
January 7, 2013 18:28
-
-
Save jakelodwick/4477243 to your computer and use it in GitHub Desktop.
Simple shell script to get your machine's current local IP.
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
# type this in a terminal window to get your current local ip address: | |
ifconfig | grep 192 | awk '{print $2}' | |
# add this to whatever file runs when you open a new shell | |
# (~/.profile on OS X) | |
alias ip="ifconfig | grep 192 | awk '{print \$2}'" | |
# now you can type "ip" in a terminal window to get your local ip. | |
# note: you can replace "ip" with whatever you want. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I recommend:
ifconfig | grep "inet " | grep -v "127.0.0.1" | awk '{ print $2 }'
... as you might not be on a 192.x subnet.