Created
July 22, 2011 00:25
-
-
Save jdlich/1098564 to your computer and use it in GitHub Desktop.
ruby one-liner to grab ip address
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
# os x (copies ip to clipboard) | |
ifconfig en1 | ruby -ne '$_.match(/inet\s((\d|\.)+)/) { print $1 }' | pbcopy | |
# ubuntu | |
# make sure you have xclip: apt-get install xclip | |
# (also make sure to paste with the middle mouse button...) | |
ifconfig eth0 | ruby -ne '$_.match(/inet\saddr:((\d|\.)+)/) { print $1 }' | xclip | |
# wrap it with a function in .bashrc (don't forget the semi-colon) | |
function ip { COMMAND; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment