Last active
August 29, 2015 14:04
-
-
Save tlehman/b909c6c8dbc55596e48c to your computer and use it in GitHub Desktop.
Just IP addresses
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
#!/bin/bash | |
# extract IP addresses from ifconfig command using Perl | |
if [ "$1" = "-v6" ]; then | |
ifconfig | perl -ne '/inet6 addr: (([0-9a-f]*:?)*\/\d+)/ && print "$1\n"' | |
else | |
ifconfig | perl -ne '/addr:((\d{1,3}\.?){4})/ && print "$1\n"' | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment