Created
July 27, 2010 17:57
-
-
Save cowboy/492588 to your computer and use it in GitHub Desktop.
Echo a list of all bound IPs. If an IP is passed, echo that IP if it is currently bound.
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
| #!/bin/bash | |
| # Tested in OS X 10.5 | |
| # | |
| # Echo a list of all bound IPs. If an IP is passed, echo that | |
| # IP if it is currently bound. | |
| IPLIST=$(ifconfig -u | grep -w 'inet' | grep -v '127[.]0[.]0[.]1' | cut -d ' ' -f 2 | sed 's/^ *//;s/ *$//') | |
| if [ $1 ]; then | |
| if [ -n "$(echo $IPLIST | grep -w $1)" ]; then | |
| echo $1 | |
| fi | |
| else | |
| echo $IPLIST | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment