Last active
April 22, 2017 12:58
-
-
Save OwenChia/478434ce0bf355c4f4cc957822dd60a4 to your computer and use it in GitHub Desktop.
getip.sed
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/sed -nf | |
# Usage: | |
# ip addr | sed -nf getip.sed | column -t | |
/^[[:digit:]]/ { | |
: begin | |
s/^[[:digit:]]\+: \([[:graph:]]\+\).*/\1/ | |
h | |
: loop | |
n | |
/^[[:digit:]]/b begin | |
s/.*inet \([[:digit:]\.\/]\+\).*/\1/ | |
T loop | |
H | |
x | |
s/\n/ / | |
p | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How it works:
h
n
H
x